How to Fix WordPress Memory Exhausted Error Solution
WordPress Memory Exhausted Error and Fatal error. Allowed memory size exhausted” message? Fix the WordPress memory limit wp-config, htaccess, php.ini. It’s one of the most common and jarring errors a WordPress user can face: “Fatal error: Allowed memory size of X bytes exhausted…” This message stops your site in its tracks, often locking you out of both the front end and your admin dashboard. This error doesn’t mean your website is broken forever. It’s simply WordPress’s way of saying it ran out of its allocated RAM (memory) while trying to perform a task. This is often caused by a resource-heavy plugin (like a complex page builder or e-commerce tool), a custom function, or a high-traffic surge. This guide will walk you through every solution, from the simplest beginner-level fix to the most advanced server-side solution, to get your site back online.
The Standard WordPress Memory Fix (wp-config.php)
This is the most common, safest, and preferred method for increasing your WordPress memory. It involves adding one line of code to a core WordPress file. You will need to access your site’s files via an FTP client (like FileZilla) or the File Manager in your web hosting control panel (like cPanel).
- Log in to your server and navigate to the root folder of your WordPress installation (this is the same folder that contains
wp-admin,wp-content, etc.). - Find the file named
wp-config.php. - Important: Download a backup copy of this file to your computer before making any edits.
- Open the
wp-config.phpfile to edit it. - Scroll to the bottom, just before the line that says
/* That's all, stop editing! Happy publishing. */. - Paste the following line of code right above it:
PHP
define( 'WP_MEMORY_LIMIT', '256M' );
This code tells WordPress to set its memory limit to 256 megabytes. If 256M doesn’t solve the issue (especially for large e-commerce sites), you can try 512M, but 256M is sufficient for most modern websites.
- Save the file and upload it back to your server, overwriting the original.
- Try accessing your website again. In most cases, the error will be gone.
If you have edited your wp-config.php file and the memory exhausted error persists, you are likely facing a different, more stubborn problem. This scenario almost always means that your web server’s global settings are overriding your WordPress settings. The server itself has a master limit (often defined in a file called php.ini), and that limit is set lower than the 256M you just requested. WordPress cannot use more memory than the server’s master configuration is willing to provide. To fix this, we must now move beyond WordPress-level files and edit the server’s configuration directly. The following advanced steps will show you how to change these server-level limits.
Advanced Server-Level Solutions
If wp-config.php didn’t work, try one of these methods. Note: These methods may not work on all hosting plans, especially basic shared hosting.
Method 1: Edit Your .htaccess File
This file is a powerful server configuration file also located in your WordPress root directory.
- Find the
.htaccessfile in your root folder (you may need to “Show Hidden Files” in your File Manager). - Download a backup copy.
- Open the file and add the following line, usually at the bottom:
php_value memory_limit 256M - Save and re-upload the file. Check your site. If this crashes your site (e.g., causes a “500 Internal Server Error”), your server is not configured to allow this. Delete the line from your
.htaccessfile and try the next method.
Use Your Host’s cPanel (MultiPHP INI Editor)
This is the modern, user-friendly way to change your PHP limits.
- Log in to your web hosting cPanel.
- Look for an icon named “MultiPHP INI Editor” or “PHP INI Editor” (it might also be under “PHP Configuration”).
- Select your domain from the dropdown menu.
- Look for the directive named
memory_limit. - Change the value in the box to
256Mand click “Apply” or “Save”. - This change is instant and is the safest way to edit server-side settings.
Method 3: Edit the php.ini File
This is the master configuration file for PHP. Access to this is often restricted on shared hosting.
- Check your root folder for a file named
php.inioruser.ini. If it exists, open it. - If it doesn’t, you may need to create a new blank file named
php.iniand upload it to your root directory. - Add the following line to the file:
memory_limit = 256M - Save and upload the file. This change may take a few minutes to take effect.
What If the Error Still Persists?
If you’ve increased your memory to 256M or even 512M and the error still occurs, you don’t just have a memory issue—you have a memory leak. This means a poorly coded plugin or theme is consuming all your memory in an endless loop.
- Solution: The only way to find the culprit is to deactivate all your plugins.
- How: If you can’t access your admin area, use FTP/File Manager to go to
wp-contentand rename thepluginsfolder toplugins_old. - If this fixes the site, you know it’s a plugin. Rename the folder back to
plugins, then go to your WordPress admin and reactivate them one by one until the error returns. The last plugin you activated is the one causing the problem.
Beyond the Quick Fix
Resolving the WordPress “memory exhausted” error is a critical skill for any site owner. It’s a clear signal that your website is either growing or being weighed down by a specific piece of code. By following these steps—starting with the WordPress-level wp-config.php fix, moving to server-level changes via .htaccess or your cPanel, and finally diagnosing a faulty plugin—you can systematically eliminate the problem. Remember, while increasing the memory limit is a good solution, it can sometimes just be a temporary patch. The long-term goal should always be to identify why so much memory is needed and ensure your site is running efficiently with well-coded themes and plugins.



