How To Fix the WordPress Memory Exhausted Error by Increasing Your Site’s PHP Memory Limit
As you may know, WordPress is built using PHP. This programming language is incredibly flexible, but it also has a few drawbacks. For example, if you don’t allocate enough memory for your WordPress installation, you might start running into the occasional “PHP Memory Exhausted” error.
In a nutshell, this error means your server isn’t allocating enough resources for WordPress to execute the PHP scripts it needs to function properly. This issue can negatively affect your site’s functionality, but there are several ways you can fix and even prevent it.
In this article, we’ll show you how to fix the memory exhausted problem by increasing your PHP memory limit. However, first, let’s talk about how to recognize this error and what it means!
Why You’re Seeing a WordPress Memory Limit Error on Your Site
As we mentioned earlier, the PHP memory limit error means you’re not allocating enough resources for your WordPress installation to function correctly. The problem usually presents itself with a message such as:
Don’t be scared by the word “fatal,” though. Your website isn’t broken, but you will need to make some changes to your WordPress installation if you want it to work properly. Specifically, you’ll want to increase your PHP memory limit.
By “PHP memory limit,” we mean the amount of server memory that’s allocated to run PHP scripts. By default, that number should be around 64 MB or higher. In most cases, 64 MB is more than enough, however.
Most hosting servers provide you with far more memory than that, so increasing the PHP allowed memory size shouldn’t negatively impact your website’s performance whatsoever. In fact, unless you’re using a cheap web host or you set up WordPress manually, your PHP memory limit shouldn’t be an issue at all.
You can easily check to see what your PHP memory limit is by accessing your WordPress dashboard and navigating to Tools > Site Health > Info. Next, you can click on the Server tab and look for the PHP memory limit entry.
Within the Server tab, you can also check other information such as your PHP version and the PHP time limit. The latter variable, which is in seconds, defines how long PHP scripts have to execute before they time out.
For now, let’s focus on the PHP memory limit. As you can see, the above example has quite a high limit, which means that the website is unlikely to run into a WordPress Memory Exhausted error.
If your site has a low memory limit (<64 MB), it’s in your best interests to increase it. There are a couple of ways you can do so.
Take Your WordPress Website to the Next Level
Whether you need help navigating your web hosting control panel, fixing an error, or finding the right plugin, we can help! Subscribe to our monthly digest so you never miss an article.
How to Resolve the WordPress Memory Limit Error (2 Methods)
As far as WordPress errors go, this one has a clear-cut cause and solution. You’re not allocating enough memory for your PHP installation, so you need to increase that number. In this section, we’ll go over two methods you can use: one manual technique and one that requires your wallet.
1. Increase the PHP Memory Allocated to Your Website Manually
WordPress enables you to declare your allowed memory size manually by modifying one of two files: .htaccess and wp-config.php. However, changing your WordPress installation’s .htaccess file can lead to site-wide errors since that file governs how it interacts with your server.
Increasing your PHP memory limit through wp-config.php is, in most cases, the safest option, and it’s remarkably easy to do. All you need is a Secure File Transfer Protocol (SFTP) client such as FileZilla that you can use to connect to your website.
Once you access your website via SFTP, open the WordPress root folder and look for the wp-config.php file within it.
Open that file using a text editor, and you should see something like this:
To increase your PHP memory limit, you can simply add a single line of code anywhere after the <?php tag and before the part of the file that reads “/* That’s all, stop editing! Happy blogging. */”.
This is the line of code to add:
define( 'WP_MEMORY_LIMIT', 'XXXM' );
You’ll need to replace the “XXX” variable within that line with the amount of memory you want to allocate to PHP. As we mentioned before, the absolute minimum you should settle for is 64 MB.
However, you can also double the number to play it safe or increase it even further. For example, if you set a PHP memory limit of 256 MB, it would look like this:
define( 'WP_MEMORY_LIMIT', ‘256M’);
Once you’re set on a number, save the changes to wp-config.php and close the editor. Now return to your WordPress dashboard and navigate to Tools > Site Health > Info > Server to see if the changes went through.
In some cases, declaring your PHP memory limit manually won’t work because you don’t have the necessary permissions to change that value. If you can’t adjust your WordPress memory size manually, that leaves you with one other option.
2. Upgrade Your Website’s Hosting Plan
Typically, if you use a decent WordPress hosting provider, you won’t need to worry about increasing your PHP memory limit. One caveat is that if you’re using shared hosting, you’ll likely face limited resources. So if you’re encountering this error, it might be time to upgrade to a better hosting plan.
Upgrading your hosting package will usually result in an increase in available PHP memory. That means you’re much less likely to run into a WordPress memory limit error. The only limiting factor is your budget.
If you can’t upgrade hosting plans right now, it might be worth contacting your provider’s support team and seeing if they can increase your PHP memory limit on their end. If they can’t, it might be time to switch to a better WordPress host that offers high PHP memory limits on affordable plans.
Skip the Stress
Avoid troubleshooting when you sign up for DreamPress. Our friendly WordPress experts are available 24/7 to help solve website problems — big or small.
Want More WordPress Error Tips?
Once you increase PHP memory on your WordPress website, we can help tackle other issues. We’ve put together several tutorials to help you troubleshoot every error message:
- How to Fix Common WordPress Errors
- How to Troubleshoot the WordPress White Screen of Death (WSoD)
- How to Fix the 500 Internal Server Error in WordPress
- How to Fix Syntax Errors in WordPress
- How to Fix the WordPress Not Sending Email Issue
- How to Fix the Error Establishing Database Connection in WordPress
- How to Fix WordPress Error 404 Not Found
- How to Fix White Text and Missing Buttons in WordPress Visual Editor
- How to Fix the Sidebar Below Content Error in WordPress (In 3 Steps)
- What to Do When You’re Locked Out of the WordPress Admin Area
- How to Fix the WordPress Login Page Refreshing and Redirecting Issue
Want more information on WordPress site management? Check out our WordPress Tutorials, a collection of guides designed to help you navigate the WordPress dashboard like an expert.
Increasing PHP Memory Limit
Running into a PHP fatal error can be worrying, but it’s not necessarily a cause for concern. Learning how to increase your PHP memory limit is relatively simple if you don’t mind using an SFTP client and adding a single line of code to one of WordPress’ core files.
The alternative is to upgrade your hosting plan or opt for a better provider. Most WordPress-friendly hosting options offer high limits by default, so you’ll never run into a PHP memory exhausted error ever again.
If you’re ready to use a web host optimized for WordPress websites, check out our DreamPress hosting packages! We offer optimized WordPress setups, so you spend less time troubleshooting errors and more time working on your website.