How to Fix the Memory Exhausted Error in WordPress (Increase PHP Memory Limit)

A complete guide on how to fix the fatal 'Memory Exhausted' error in WordPress by safely increasing your PHP memory limit via wp-config.php, .htaccess, or php.ini.

How to Fix the Memory Exhausted Error in WordPress (Increase PHP Memory Limit)

One of the most intimidating errors a WordPress user can encounter is a completely blank white screen accompanied by a single line of highly technical text:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/user/public_html/wp-includes/plugin.php on line 123

This is known as the WordPress Memory Exhausted Error. It often goes hand-in-hand with the infamous White Screen of Death (WSoD). While the error message looks like your website has been permanently broken, the actual cause is incredibly simple: WordPress simply ran out of RAM.


Why Does WordPress Run Out of Memory?

WordPress is written in a programming language called PHP. Every time a user visits your site, PHP scripts run on your web server to process the database, load plugins, and generate the HTML page.

To prevent a single poorly coded script from crashing the entire server, hosting providers assign a strict PHP Memory Limit to each website. By default, WordPress attempts to allocate 40MB for single sites and 64MB for multisite installations. However, many budget shared hosting providers restrict this limit to as low as 32MB.

When you install a resource-heavy plugin (like WooCommerce, Elementor, or a complex SEO tool), the PHP script requires more RAM than the server allows. The server immediately kills the process, resulting in the “Memory Exhausted” fatal error.


How to Fix the Error (Increase PHP Memory Limit)

You can usually fix this error yourself in less than 5 minutes by manually overriding the default memory limit. There are three primary methods to do this.

This is the safest and most reliable method to increase your WordPress memory limit.

  1. Connect to your website using an FTP client (like FileZilla) or use the File Manager in your hosting cPanel.
  2. Navigate to your root directory (public_html).
  3. Locate the wp-config.php file, right-click, and select Edit.
  4. Scroll down until you find the line that says: /* That's all, stop editing! Happy publishing. */
  5. Just above that line, paste the following PHP snippet:
define( 'WP_MEMORY_LIMIT', '256M' );

This tells WordPress to request 256MB of memory from the server, which is more than enough for almost all standard websites. Save the file and refresh your website.

Method 2: Edit your .htaccess file

If editing wp-config.php didn’t work, your server might require the limit to be set at the Apache level.

  1. In your File Manager, look for a hidden file named .htaccess. (Make sure “Show Hidden Files” is enabled in cPanel settings).
  2. Edit the file and paste the following line at the very bottom:
php_value memory_limit 256M

Save the file. Note: If this causes a 500 Internal Server Error, delete the line immediately, as it means your server does not allow PHP overrides via .htaccess.

Method 3: Edit your php.ini file

If you are on a VPS or a dedicated server, you will need to edit the global PHP configuration file.

  1. Locate your php.ini file (often in a cgi-bin folder or editable via a “MultiPHP INI Editor” in cPanel).
  2. Search for the memory_limit line and change it:
memory_limit = 256M

What if the Error Persists?

If you have tried all three methods and you are still seeing the memory exhausted error, it means your hosting provider has hard-locked your PHP memory limit at the server root. No matter what code you add to your files, the host will not allow you to use more RAM.

Running a modern, dynamic WordPress site on a locked, low-memory server is a recipe for constant crashes. To guarantee your site has the resources it needs to scale, you should migrate to a premium environment. Our WordPress Hosting plans are engineered specifically for resource-intensive setups, providing ample memory limits by default so you never have to deal with fatal exhaustion errors again.

Ensure your resource-heavy plugins have adequate headroom by choosing Nextgen Hosting’s cPanel plans.