If you’re seeing the “Allowed memory size of bytes exhausted” error, particularly when you’re trying to do something in the dashboard, you’re probably feeling frustrated.
This is a common WordPress error, and it can really get in the way. Maybe you’re seeing it when trying to use a certain plugin in the back end, or maybe users are emailing you complaining that something doesn’t work.
Whatever the case, your site’s functionality is damaged and you want a fix now. We have a few quick solutions to help you stop the memory exhausted error in WordPress and get your site working again.
Table of contents
What causes the WordPress memory exhausted error?
Every website has a particular amount of memory, or RAM, it’s able to use. This is determined by your web hosting package and how much RAM your web server has access to.
Additionally, every WordPress site has a “memory limit”, which determines how much of that RAM any one PHP script is allowed to use. If a script exceeds this memory usage limit, then you’ll see the memory exhausted error.
But what exactly causes this memory exhaustion to happen? There are a few common culprits.
1: Large plugins and themes – Resource-intensive plugins and themes and those that run complex scripts can cause this fatal error.
2: Inefficient code – Unoptimized plugins, themes, or custom code can lead to excessive memory consumption. Particularly bad code can cause a memory leak, which makes your website take up more and more memory until it crashes.
3: Large media files – Attempting to upload very large media files (images, videos, audio) can exhaust memory. You should optimize images and video before uploading them to your site.
4: High traffic – Websites experiencing a traffic surge, especially sites with poorly optimized PHP scripts, can use up too many resources for your website to handle.
While it’s often best to address the problem causing the memory exhaustion (poorly coded plugins, huge media files that need to be optimized, etc), it may be that your WordPress memory limit is set way too low.
How to fix the WordPress memory exhausted error
If you’re having the WordPress memory limit error message, there’s an easy fix: increase WordPress memory limit. Each of the methods below involves editing one of three website configuration files: wp-config.php, php.ini, and .htaccess.
Additionally, there are actually two memory limit parameters: memory_limit and max_memory_limit.
memory_limit handles the PHP memory limit on the front end (your website), while max_memory_limit handles the limit on the back end (your admin dashboard). Depending on where you’re encountering the memory limit error, you may want to increase one or both.
Before you follow any of these steps, make sure you backup your website. It’s always good practice to do this before editing any sensitive files, as one wrong change could break your site.
There are three different methods for fixing this issue. Pick the one that makes the most sense for your situation.
Method 1: Edit wp-config.php
Most web hosts allow you to access your website files through FTP/SFTP, and this is an easy and direct way to edit your site’s files.
1: The first thing you’ll need is your FTP credentials. Your WordPress hosting provider will likely allow you to access your site through FTP. If your host uses cPanel, you can log in and look in the Files section for the FTP Accounts link. Otherwise, ask your host for your credentials.
2: Next, you’ll need an FTP client, such as FileZilla. Install FileZilla, then open it.
3: Enter your FTP credentials (Host, Username, Password, Port) into the bar at the top and click Quickconnect.
Now it’s time to edit the configuration files. All three of these files can be found in the root directory of your website, which is usually where you’ll find yourself once you click Quickconnect. It may also be located in the public_html folder.
We’ll start with wp-config.php.
1: Locate wp-config.php in your website’s root directory. Right click it and click Edit. It will open in Notepad or a similar program.
2: Look for the values WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT, for example: define(‘WP_MEMORY_LIMIT’, ’64M’); and define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);
3: If you can’t find these values, paste them above this line: /* That’s all, stop editing! Happy publishing. */
4: Increase these values by changing the number, such as ‘64M’. These values are typically doubled (64M, 128M, 256M, etc). Try increasing it by one step at a time. For example: define(‘WP_MEMORY_LIMIT’, ’64M’);
5: Save your changes and upload them to your server.
You can also use your host’s cPanel to edit the wp-config.php file.
Most web hosts have a site management panel of some sort, and cPanel is a very common one. You can access and edit site panels through cPanel, and you don’t even need to install a client like with FTP. cPanel is accessible through your web browser.
Not all web hosts use cPanel, however. Check your host’s documentation to see if they do. If they use a custom site management panel, there may be a similar file editor tool.
Here’s how to access the file editor in cPanel.
1: Login to cPanel. If you’re not sure what your login details are, ask your web host.
2: Look in the Files section for File Manager and open it.
3: Locate your website’s root folder (look for core files like the wp-admin and wp-content folders). It may be in a folder called public_html.
Now here’s how you can edit wp-config.php in cPanel.
1: Locate wp-config.php in your website’s root directory. Right click it and click Edit. It will open in a new tab.
2: Look for the values WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT, for example: define(‘WP_MEMORY_LIMIT’, ’64M’); and define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);
3: If you can’t find these values, paste them above this line: /* That’s all, stop editing! Happy publishing. */
4: Increase these values by changing the number, such as ‘32M’. These values are typically doubled (64M, 128M, 256M, etc). Try increasing it by one step at a time. For example: define(‘WP_MEMORY_LIMIT’, ’64M’);
5: Click Save Changes.
Method 2: Edit php.ini
Another way to fix this problem is to edit the php.ini file. Not all websites have a php.ini file, but you can create one.
If you go the FTP route, here are the steps you can take:
1: Locate php.ini in your website’s root directory. If you don’t have one, create a file and name it php.ini. Right click the file and click Edit.
2: Look for the values memory_limit and max_memory_limit, for example: memory_limit = 64M and max_memory_limit = 256M
3: If you can’t find these values, paste them in at the bottom of the document.
4: Increase these values by changing the number, such as ‘64M’, one step at a time. For example: memory_limit = 64M
5: Save your changes and upload them to your server.
If you’re using cPanel, here’s how to edit php.ini.
1: Locate php.ini in your website’s root directory. If you don’t have one, click the File button next to a plus icon in the top left corner, and name the file php.ini, placing it in your root directory. Right click the file and click Edit.
2: Look for the values memory_limit and max_memory_limit, for example: memory_limit = 64M and max_memory_limit = 256M
3: If you can’t find these values, paste them in at the bottom of the document.
4: Increase these values by changing the number, such as ‘64M’, one step at a time. For example: memory_limit = 64M
5: Click Save Changes.
Method 3: Edit .htaccess
The third and final method we’ll discuss here today is editing the .htaccess file. Note that only Apache servers have an .htaccess file – if you don’t see one, you probably have an NGINX server.
However, this is often a hidden file, so you’ll need to switch on a certain setting to check if you have an .htaccess file. If you don’t see .htaccess after enabling hidden files, you probably don’t have one, so just skip these steps.
1: To access this file using FTP, click Server in FileZilla’s menu bar, then click Force showing hidden files. This will allow you to see the normally-hidden .htaccess file.
2: Locate .htaccess in your website’s root directory. Right click the file and click Edit.
3: Look for the values php_value memory_limit and php_value max_memory_limit, for example: php_value memory_limit 64M
4: If you can’t find these values, paste them in below this line: #END WordPress
5: Increase these values by changing the number, such as ‘32M’, one step at a time. For example: php_value memory_limit 64M
6: Save your changes and upload them to your server.
If using cPanel, you can get to .htaccess through the File Manager. This is an Apache-only file, so if you have an NGINX server, you won’t have one. If you don’t see .htaccess after enabling hidden files, just skip these steps.
1: Click the Settings button in the top right corner and enable Show hidden files.
2: Locate .htaccess in your website’s root directory. Right click the file and click Edit.
3: Look for the values php_value memory_limit and php_value max_memory_limit, for example: php_value memory_limit 64M and php_value max_memory_limit 256M
4: If you can’t find these values, paste them in below this line: #END WordPress
5: Increase these values by changing the number, such as ‘64M’, one step at a time. For example: php_value memory_limit 64M
6: Click Save Changes.
And that’s all – check if the issue is fixed, and increase the memory limit one increment at a time until it works.
What if none of this fixes the error? Sometimes a plugin, theme, or line of code is using extreme amounts of memory and needs to be removed.
Otherwise, the issue is probably that your web host either does not have enough memory to allocate, or is enforcing a very low memory limit. This is common on shared hosting.
Sometimes you can contact your web host and ask them to raise the memory limit, but not all will bend their policies. If not, the only solution is to upgrade your web hosting and pick a hosting plan with more powerful options.
Memory exhausted error fixed
Now you know how to fix the WordPress memory exhausted error: by editing wp config, php.ini, and .htaccess. It’s usually a quick and easy fix that can be done through FTP or cPanel.
Hopefully, your website is up and running again properly, but if the issue can’t be fixed, you may need to upgrade your hosting. If you suspect broken code is at play, read our guide to debugging common WordPress issues.