Few things are as frustrating for a website owner as opening your site only to be greeted by a blank screen or a cryptic line of code. One of the most common issues WordPress users encounter is the Fatal Error: Allowed Memory Size Exhausted. This error typically indicates that your website has reached the default memory allocation limit set by your server or WordPress installation. While it looks intimidating, it is actually a standard “resource limit” issue that can be resolved with a few simple tweaks to your site’s configuration files.

What Causes the Memory Exhaustion Error?

To understand why this happens, think of your web server like a computer’s RAM. Every time a script runs—whether it’s a plugin, a theme, or a WordPress core update—it requires a certain amount of memory.

By default, hosting providers and WordPress set a specific PHP memory limit to prevent a single poorly written script from hogging all the server’s resources. When a script requires more memory than the limit allows, the system shuts it down to protect the server, resulting in the Fatal Error: Allowed Memory Size Exhausted. This often occurs during heavy tasks like:

  • Installing a large, feature-heavy plugin.
  • Updating WordPress core.
  • Processing high-resolution images.
  • Running complex database queries.

Step 1: Increase PHP Memory Limit via wp-config.php

The most effective way to resolve this is by manually telling WordPress to request more memory from the server. You can do this by editing your wp-config.php file, which is located in the root directory of your WordPress installation.

  • Connect to your site using an FTP client (like FileZilla) or the File Manager in your hosting CPanel.
  • Locate the wp-config.php file and open it for editing.
  • Scroll down to the line that says: /* That's all, stop editing! Happy publishing. */
  • Just above that line, paste the following code: define( 'WP_MEMORY_LIMIT', '256M' );
  • Save the file and refresh your website.

Setting the limit to 256M is usually sufficient for most modern WordPress sites. If the error persists, you can try increasing it to 512M, though you should check with your hosting provider if your plan supports it.

Step 2: Edit Your .htaccess File

If the wp-config.php method doesn’t work, your server might be overriding the WordPress settings. In this case, you can try to increase the limit through your .htaccess file.

  • Access your site’s root directory via FTP.
  • Locate the .htaccess file (ensure “show hidden files” is enabled in your FTP client).
  • Add the following line to the end of the file: php_value memory_limit 256M
  • Save and check your site.

Step 3: Modify the php.ini File

For those on a VPS or a dedicated server, you might have access to the php.ini file. This is the global configuration file for PHP on your server.

  • Find the php.ini file (often in the public_html or etc folder).
  • Look for the line that starts with memory_limit.
  • Change the value to memory_limit = 256M.
  • Restart your server or wait a few minutes for the changes to take effect.

Note: If you are on shared hosting, you might not see this file. If you are struggling with these technical steps, you may want to check out our guide on WordPress technical management for more hands-on help.

Step 4: Identify the “Memory Hog.”

While increasing the limit fixes the symptom, it doesn’t always fix the cause. If a specific plugin is poorly coded, it might continue to drain memory regardless of how high you set the limit.

  • Deactivate Plugins: Go to your dashboard and deactivate all plugins. If the error disappears, reactivate them one by one until the error returns. Once you find the culprit, check for updates or find a lighter alternative.
  • Switch Themes: Sometimes a heavy theme is the reason for the Fatal Error: Allowed Memory Size Exhausted. Temporarily switch to a default theme like Twenty Twenty-Four to see if the memory usage drops.
  • Update PHP: Ensure your server is running a modern version of PHP. Newer versions are significantly more memory-efficient than older ones. You can find the latest requirements on the official WordPress requirements page.

Conclusion

Encountering the Fatal Error: Allowed Memory Size Exhausted can be a headache, but it is a manageable issue. By increasing your PHP memory limit through wp-config.php or .htaccess, you give your website the “breathing room” it needs to function correctly.

However, always remember that a well-optimized site is a fast site. Regularly audit your plugins, keep your media library organized, and ensure your hosting plan aligns with your site’s traffic and complexity. If you’ve tried all the steps above and the error still won’t budge, it might be time to contact your hosting provider’s support team to see if there are server-side restrictions in place.