How To Increase WordPress PHP Memory Limit: Step-by-Step Guide
WordPress powers a significant portion of the web, operating on PHP, a robust server-side scripting language. Like any application, PHP requires dedicated memory to execute scripts, process media, query databases, and run active plugins. By default, many hosting providers set the PHP memory limit conservatively to prevent a single website from consuming excessive shared server resources. When your site outgrows these constraints, you will inevitably encounter the "Fatal Error: Allowed memory size exhausted" message.
This technical issue typically manifests as a blank white screen, often referred to as the White Screen of Death, or as a specific error message within your admin dashboard. This happens when a dynamic script or a resource-heavy plugin attempts to utilize more memory than the allocated threshold. Fortunately, resolving this issue is straightforward once you understand how to safely modify your server configuration files. This comprehensive guide walks you through why memory limits exist and the exact steps to increase them safely.
Why Does WordPress Run Out of Memory?
To understand why your website runs out of memory, it is essential to analyze the underlying architecture of WordPress. Every time a visitor loads a page, the server triggers a series of operations: loading core system files, executing theme functions, and running active plugins. If you operate a resource-intensive website, such as an e-commerce store powered by WooCommerce or a dynamic community forum, your PHP memory requirements rise exponentially.
Visual page builders like Elementor, Divi, or WPBakery are also notorious for heavy memory consumption. These tools process massive amounts of design options, layouts, and scripts on the fly, pushing standard server limits to their breaking point. When multiple resource-heavy plugins are activated simultaneously, they compete for the same pool of allocated memory, resulting in execution failures.
Furthermore, automated background processes heavily contribute to memory exhaustion. Scheduled site backups, security scans, search engine indexing, and cron jobs require significant memory resources to scan directories and modify database tables. If these administrative tasks run concurrently with peak user traffic, the allocated memory pool drains completely, causing your server to drop the process.
Lastly, poorly coded plugins or outdated active themes can cause memory leaks. This developer term refers to a situation where a script repeatedly requests memory allocation but fails to release it back to the server once the task is finished. Even if you have a generous memory allocation, a rogue script with a memory leak can easily bypass your limit, resulting in severe performance degradation or complete site crashes.
How to Check Your Current WordPress PHP Memory Limit
Before making any structural changes to your server files, you must determine your website's current PHP memory allocation. WordPress contains an integrated diagnostic utility called Site Health that provides detailed insights into your server environment. To access this tool, log in to your WordPress admin dashboard, navigate to Tools, and click on Site Health.
Once inside, click on the Info tab located at the top of the interface. Scroll down the page and expand the Server accordion menu. Here, you will find critical technical details about your hosting environment, including your PHP version, post max size, file upload limits, and the active PHP memory limit. If your limit is set to 40M or 64M, your site is operating on bare minimum requirements. Modern websites require at least 128M, while complex sites perform best at 256M or higher.
Alternatively, you can verify this value by creating a PHP information file. Using an FTP client or your hosting provider's File Manager, navigate to your root directory (usually public_html) and create a new file named info.php. Add the text to this file, save it, and visit yourdomain.com/info.php in your browser. This page displays your entire server configuration; search for "memory_limit" to find the exact value. Always delete this file immediately after checking to prevent exposing sensitive server paths to potential attackers.
Fix the WordPress memory exhausted error increasing the PHP memory ...
Methods to Increase WordPress Memory Limit
Method 1: Editing the wp-config.php File
The most common and recommended way to increase your memory limit is by editing the wp-config.php file. This file resides in the root directory of your WordPress installation and contains your core configuration data, including database credentials and security keys. By modifying this file, you instruct WordPress to request a higher memory allocation from the PHP environment prior to executing core scripts.
To begin, connect to your server using an FTP client or the File Manager in your hosting control panel. Locate the wp-config.php file, and download a copy to your computer as a secure backup before making any edits. Open the server-side file in a text editor and scroll down near the bottom of the document.
Look for the line that reads: /* That's all, stop editing! Happy publishing. */. Directly above this line, input the following statement: define('WP_MEMORY_LIMIT', '256M');. If you are running complex operations or need more memory in the admin dashboard, you can also add: define('WP_MAX_MEMORY_LIMIT', '512M');. Save the file and upload it back to your server, overwriting the old version.
Method 2: Modifying the .htaccess File
If editing the WordPress configuration file does not resolve the issue, your hosting server may be enforcing constraints at the server software level. For websites hosted on Apache servers, you can use the .htaccess file to override global PHP configurations. This file handles redirects, security parameters, and directory-specific server instructions.
Access your root directory via FTP or File Manager. Because .htaccess is a hidden system file, ensure that your file viewer has "Show Hidden Files" enabled. Download a backup copy of the existing .htaccess file to your computer to safeguard your site against configuration mistakes.
Open the file and navigate to the bottom of the page, outside of the block marked # BEGIN WordPress. Insert the following line: php_value memory_limit 256M. Save your changes and upload the file back to your server. Check your website immediately to ensure it loads correctly; if you encounter a 500 Internal Server Error, your host has likely restricted Apache overrides, meaning you must revert the file and try another method.
Method 3: Editing the php.ini or user.ini File
The php.ini file serves as the master configuration file for PHP settings on your web server. If your host restricts changes within WordPress and Apache files, adjusting your PHP initialization file is the next logical step. On shared hosting environments, you may not have access to the global php.ini file, but you can create a local override file.
Connect to your server and navigate to your public_html folder. Look for an existing file named php.ini or .user.ini. If neither file exists, create a new blank file and name it php.ini. If your host utilizes a CGI or FastCGI setup, name the file .user.ini instead.
Open this file and add the following instruction: memory_limit = 256M. You can also increase your script timeout settings here by adding max_execution_time = 300 to prevent other common server timeout errors. Save and upload the file to your root folder. Note that it can take up to ten minutes for some servers to register changes made to local INI files.
Method 4: Using cPanel MultiPHP INI Editor
For website owners who prefer to avoid manual code editing, many modern hosting providers offer a graphical utility within the cPanel interface. The MultiPHP INI Editor allows you to easily adjust system-level PHP parameters without risk of breaking file syntax.
Log in to your hosting account and locate the Software or Services section in cPanel. Click on the MultiPHP INI Editor icon to open the tool. You will be prompted to select your active WordPress domain from a dropdown menu.
Once selected, cPanel will display a list of editable PHP configurations. Scroll down until you find the directive labeled memory_limit. Replace the existing value with 256M (or 512M if required) and click the blue Apply button. The system will write the necessary configurations to your server files automatically.
Method 5: Contacting Your Hosting Provider
When manual configurations, file edits, and cPanel adjustments fail, it is highly likely that your hosting provider enforces a hard resource cap. This is common in budget-friendly shared hosting plans where resource allocations are strictly locked to prevent individual sites from overloading the shared hardware.
In this situation, you must reach out to your host's technical support team. Submit a support ticket or open a live chat session, stating that you are encountering a PHP memory limit exhaustion error on your WordPress site. Request that they manually increase your server-level limit to 256M.
Reputable hosting providers will complete this request promptly. However, if your current hosting plan has reached its absolute maximum limitation, support may suggest upgrading your service. Moving to a Managed WordPress host or a Virtual Private Server (VPS) provides dedicated resources and full control over PHP allocations.
Comparison of Methods to Increase Memory Limit
Selecting the optimal method depends on your technical comfort level and your hosting infrastructure. While editing wp-config.php is the industry standard for WordPress, it only instructs the application on how much memory to request. If your server software has a lower absolute limit configured, the application-level request will be ignored.
The table below highlights the differences between each adjustment method:
| Method | Ease of Use | Server Access Needed | Risk Level | Target Server Environment |
|---|---|---|---|---|
| wp-config.php | High | FTP or File Manager | Low | All Web Servers (WordPress Level) |
| .htaccess | Medium | FTP or File Manager | Medium | Apache Web Servers |
| php.ini / .user.ini | Medium | FTP or File Manager | Medium | CGI / FastCGI Servers |
| cPanel MultiPHP | High | cPanel Account Login | Low | cPanel-enabled Linux Hosts |
| Hosting Support | Very High | None (Support Ticket) | Low | All Hosting Providers |
As shown above, graphical tools and direct support inquiries present the lowest risk to your site's uptime. If you perform manual file updates via FTP, always keep clean backups handy to quickly restore your site in the event of a configuration conflict.
Pros and Cons of Increasing PHP Memory Limit
Increasing your PHP memory limit offers several distinct advantages, primarily centered on operational stability. Providing your plugins and themes with a larger resource pool prevents unexpected crashes and eliminates the White Screen of Death. This is crucial for maintaining a seamless user experience on high-traffic websites and e-commerce stores.
Furthermore, a higher memory limit allows you to run feature-rich tools safely. Security scanners, page builders, translation systems, and analytics trackers require substantial system resources. Expanding your memory limit ensures these business-critical applications can perform operations, process database queries, and load assets without lagging.
However, raising the memory limit can sometimes mask underlying code inefficiencies. If your site contains a poorly coded plugin with a memory leak, increasing the memory allocation only acts as a temporary patch. The bad script will eventually consume the new memory pool as well, resulting in delayed crashes rather than a permanent solution.
Additionally, setting excessively high limits (such as 1024M or higher) on shared hosting environments can lead to resource starvation. If multiple sites on a single server attempt to utilize massive memory allocations simultaneously, the server may run out of physical RAM, triggering hosting security systems to temporarily suspend your account for resource abuse.
Troubleshooting Common Issues After Increasing Memory Limit
If you have completed the steps above but your Site Health tool still displays the old memory limit, you may be experiencing server caching. Web hosts often implement aggressive server caching protocols (like Varnish, Redis, or Memcached) to improve speeds. Clear all caching layers via your hosting panel and flush your WordPress caching plugins to force the server to read the updated files.
Another roadblock is a global override from your hosting provider. On managed hosting setups, providers often hardcode configuration limits within the primary server directory. When this occurs, any local modifications you apply to .htaccess or php.ini are disregarded by the active PHP engine, making a direct support request your only path forward.
Lastly, double-check your syntax. PHP files are highly sensitive to formatting errors. For example, if you pasted the wp-config.php code using curly quotes instead of straight single quotes, the server will fail to compile the file. If you encounter a 500 error after making changes, revert your file to the backup copy and verify the formatting of your code snippet.
Frequently Asked Questions
What is the default WordPress PHP memory limit?
By default, WordPress attempts to allocate 40MB of memory for single-site installations and 64MB for multisite setups. However, these baseline limits are frequently overridden by your server's default configuration, which typically ranges from 64MB to 128MB.
Can a high memory limit slow down my WordPress site?
No, raising your memory limit does not inherently slow down your site. However, if your site is utilizing high memory because of bloated or inefficient plugins, those resource-heavy scripts will negatively impact your loading speeds.
Is 512M memory limit too high for WordPress?
For standard blogs and business websites, 256M is more than sufficient. A limit of 512M is generally reserved for highly complex websites, large WooCommerce stores, membership platforms, or development environments that execute complex database queries.
Why do my memory limit changes keep reverting?
If your memory limit changes do not stick, your hosting provider likely has automated server scripts that periodically overwrite user configuration files, or they enforce global server caps that block local user overrides.
What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
WP_MEMORY_LIMIT configures the memory allocation for front-end tasks experienced by your website visitors. WP_MAX_MEMORY_LIMIT controls the memory available for administrative tasks in the backend dashboard, such as file imports, database updates, and plugin installations.
Optimize Your WordPress Performance Today
Configuring your server's technical environment is essential for maintaining a fast, stable, and secure WordPress website. If you are tired of dealing with slow loading times, frequent database connection errors, or recurring memory exhaustion issues, it may be time to partner with hosting experts. Our managed WordPress hosting plans come pre-optimized with high memory allocations, fast SSD storage, and expert 24/7 technical support to keep your site running smoothly. Contact us today to upgrade your infrastructure and unlock your website's full potential!
