Home/WordPress Support Resource Hub/How to Fix the WordPress Memory Exhausted Error (Step by Step)
Fast answer

The WordPress memory exhausted error is a PHP fatal error triggered when a script needs more memory than allowed. Raise WP_MEMORY_LIMIT in wp-config.php, then find the plugin or theme that is leaking memory so the error does not come back.

Last updated July 14, 2026
Written by Mark Anthony Garcia
Publishing standard Fast answer, scoped workflow, tradeoffs, edge cases, next step, and citations where needed.
Author profile Editorial policy Review policy Monetization disclosure

How to Fix the WordPress Memory Exhausted Error (Step by Step)

WordPress memory exhausted error diagram: a maxed PHP memory bar fixed by raising WP_MEMORY_LIMIT to 256M
The WordPress memory exhausted error happens when a PHP script needs more memory than your site is allowed to use.

The WordPress memory exhausted error means a PHP script asked for more memory than your allowed memory size permits, so the process stops with a fatal error. To fix it, raise the WordPress memory limit in wp-config.php (or php.ini), find the heavy plugin or theme using too much memory, and ask your hosting provider for more if needed.

Few WordPress issues feel as abrupt as a blank page and the line “Allowed memory size of X bytes exhausted”. One minute your site works, the next a PHP script hits the memory cap and WordPress simply stops. The good news: this is one of the most fixable errors in WordPress. This guide explains what the error message means, what causes it, and the ways to fix it: how to increase the memory limit, find the plugin that ate the memory, and keep your WordPress website running.

What is the WordPress memory exhausted error?

Every PHP script that runs your WordPress site is allowed to use a fixed amount of memory. When a script needs more than that, PHP halts it and writes a fatal error to the screen or the debug log. The full message usually reads something like:

Fatal error: Allowed memory size of 268435456 bytes exhausted
(tried to allocate 20480 bytes) in /home/site/public_html/wp-includes/...

That number is the byte value of your PHP memory limit (268435456 bytes is 256MB). The “tried to allocate” part is the extra memory the script wanted but could not get. So the error is not random corruption: it is a hard ceiling. Either the script genuinely needs more memory, or something is using far more memory than it should. In both cases the memory size exhausted message points to the same fix: give PHP enough memory, or stop whatever is wasting it.

What causes the WordPress memory exhausted error?

The memory exhausted error in WordPress almost always comes from one of these causes:

  • A PHP memory limit that is too low. Many hosts still set the default WordPress memory to 64MB or 128MB. A modern site with several plugins and themes can pass that during normal work.
  • A heavy plugin or theme. A single poorly built plugin or theme can request a large amount of memory on one page load, for example during a backup, an import, or an image-heavy archive.
  • A memory leak. A plugin that fails to free up memory in a loop (a memory leak) can grow its memory consumption until it passes the limit.
  • Large operations. Bulk imports, big media uploads, WooCommerce reports, and page builders all spike memory usage.
  • An undersized hosting plan. Budget shared plans cap server memory tightly, so even a healthy site can run out of room.
  • Malware. Injected code can drive memory usage up as it runs hidden tasks on each request.

Memory exhaustion often shows up alongside other failures. If your screen is fully blank, read our guide to the WordPress white screen of death, and if you see the generic fatal notice, see how to fix the WordPress critical error. A memory limit error is one common trigger behind both.

How to check your current PHP memory limit

Before you change anything, confirm how much memory WordPress thinks it has. In your dashboard, go to Tools → Site Health → Info → Server and look for the PHP memory limit value. You can also see the WordPress memory limit (sometimes shown as the WP memory limit) under the WordPress constants section. If you can reach the WordPress dashboard at all, this tells you how much available memory you start with and the number you need to raise.

If the admin area itself is down, ask your hosting provider for the current PHP memory limit, or add a small check to a file in your WordPress root. Knowing the current value (for example 128MB) tells you whether you have room to grow on your plan or whether the server memory is already maxed out.

How to fix the WordPress memory exhausted error: step by step

Work through these steps in order. The first two solve most cases. Stop as soon as the error clears.

  1. Increase the WordPress memory limit in wp-config.php. Connect over SFTP or your host file manager, open wp-config.php in your WordPress root, and add this line above the comment that says “That’s all, stop editing”:
    define( 'WP_MEMORY_LIMIT', '256M' );
    define( 'WP_MAX_MEMORY_LIMIT', '512M' );

    WP_MEMORY_LIMIT raises the front-end limit; WP_MAX_MEMORY_LIMIT covers heavy admin tasks like media and imports. This is the quickest way to increase your PHP memory limit. Save, reload, and check whether the fatal error is gone.

  2. Raise the PHP memory limit in php.ini. If wp-config.php cannot raise the memory limit far enough, the host may cap PHP itself. Edit (or create) php.ini in your WordPress root and set:
    memory_limit = 256M

    On many hosts the cleaner route is the control panel: look for a PHP settings or “PHP options” screen and raise memory_limit there.

  3. Try the .htaccess method. On Apache servers without php.ini access, open .htaccess in your WordPress root and add:
    php_value memory_limit 256M

    Remove this line if it triggers a 500 error, which means your host blocks php_value directives.

  4. Find the plugin or theme using the memory. If raising the limit only delays the crash, something is using too much memory. Deactivate all plugins, then reactivate them one at a time, reloading the page that failed after each one. The plugin that brings the error back is your culprit.
  5. Switch to a default theme. Temporarily activate a default WordPress theme such as Twenty Twenty-Four. If the error clears, your theme is the source and needs an update or a replacement.
  6. Ask your hosting provider or upgrade. If you have raised every limit and still hit the cap, your plan may not allow more memory than the server budget. Ask support to confirm the hard limit and see if they can increase it, or move to a plan with a higher memory allocation.

wp-config.php vs php.ini vs .htaccess: which one to edit

People often try all three at once and get confused about which actually worked. Here is the decision in plain terms:

  • wp-config.php is the WordPress-level control. It sets WP_MEMORY_LIMIT, which WordPress uses to request memory from PHP. Start here because it is safe, portable, and works on most managed WordPress hosting.
  • php.ini is the server-level control. Its memory_limit is the real ceiling. If php.ini sits below your WordPress value, WordPress can never go higher than the server allows, so this is the file to raise when wp-config.php has no effect.
  • .htaccess is the fallback for Apache shared hosting that does not expose php.ini. It is the least reliable option and some hosts ignore or block it.

The rule of thumb: edit the wp-config.php file first, then php.ini (or the host PHP settings panel) if the server caps you, and only reach for .htaccess when you have no other way in. If your host runs LiteSpeed or Nginx, the php.ini or control-panel route is the one that counts.

Which plugin ate the memory? A quick diagnostic

Raising the limit treats the symptom. To find the cause, run a short diagnostic. Install Query Monitor on a staging copy and load the page that crashes: it reports peak memory usage and the slowest, heaviest queries on that request. The WordPress Health Check & Troubleshooting plugin is also useful because it disables plugins only for your session, so visitors never see a broken site while you test.

If you cannot log in, use the deactivate-half method over SFTP: rename the plugins folder to plugins-off to disable everything, confirm the site loads, then restore plugins in batches until the memory limit error returns. A plugin that spikes memory on every page can also slow your whole site, so it is worth pairing this with our guide to reduce TTFB on WordPress. For a full failure map across critical errors, white screens, and database issues, our WordPress troubleshooting guide walks the whole flow.

How to prevent WordPress memory errors

Once your site is stable, a few habits keep memory exhaustion from coming back:

  • Right-size your plan. If your site regularly needs more memory than a budget plan allows, compare WordPress hosting plans, because a host optimized for WordPress with a higher memory allocation (more allocated memory per request) pays for itself in uptime.
  • Keep plugins lean. Every active plugin adds to memory consumption. Remove anything you do not use and avoid stacking plugins that do the same job.
  • Run a current PHP version. Newer PHP versions handle memory more efficiently than older PHP versions, so an upgrade often lowers usage and improves speed at the same time.
  • Watch heavy operations. Schedule big imports and backups for quiet hours so they do not collide with live traffic.
  • Set a sensible limit, not a huge one. 256M suits most business sites. Pushing the limit very high can hide a memory leak instead of fixing it.

When to call a developer

If the error returns after every fix, points at core WordPress files, or appears together with malware warnings, bring in help rather than raising the limit again. A developer can profile the request, trace the memory leak, and clean an infected site safely. Our team handles this daily through GEENXT WordPress support, from quick memory-limit fixes to full diagnostics on sites that keep running out of memory.

Frequently asked questions

What is the WordPress memory exhausted error?

It is a PHP fatal error that appears when a script needs more memory than your allowed memory size permits. WordPress stops the request and shows “Allowed memory size of X bytes exhausted”, often as a blank page or a critical error notice.

What causes the WordPress memory exhausted error?

The common causes are a PHP memory limit set too low, a heavy plugin or theme, a memory leak, large imports or media operations, an undersized hosting plan, and sometimes malware. Each one pushes memory usage past the cap your server allows.

How do I check my current PHP memory limit in WordPress?

Go to Tools, then Site Health, then Info, then Server, and read the PHP memory limit value. You can also ask your hosting provider. Knowing the current number tells you how much room you have to raise it.

How do I increase the PHP memory limit in WordPress?

Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php first. If the server still caps you, raise memory_limit to 256M in php.ini or your host PHP settings panel, then reload the page that failed.

Should I edit wp-config.php, php.ini, or .htaccess?

Start with wp-config.php because it is the safe WordPress-level setting. Move to php.ini (or the host PHP panel) when the server caps you below your WordPress value. Use .htaccess only on Apache hosts that expose no php.ini.

Do plugins or themes cause memory exhausted errors?

Yes. A single heavy or poorly coded plugin or theme can use far more memory than the rest of the site combined. Deactivate plugins one by one, and test a default WordPress theme, to find which one is responsible.

Should I upgrade my hosting plan to fix memory issues?

Upgrade if you have already raised every limit and still hit the cap, which usually means the server memory budget on your plan is the real ceiling. A plan with a higher memory allocation gives your PHP scripts the room they need.

How can I prevent WordPress memory errors in the future?

Keep plugins lean, run a current PHP version, schedule heavy imports for off-peak hours, set a sensible memory limit (256M for most sites), and choose hosting sized for your traffic. These habits keep memory consumption well under the limit.

Sources: WordPress.org: Increasing memory allocated to PHP · php.net: memory_limit directive · WordPress.org: Common WordPress errors.

Avatar of Mark Anthony Garcia
Written by

Mark Anthony Garcia

Contributing author at GEENXT. Passionate about sharing knowledge and insights.

Next step

Need hands-on WordPress troubleshooting support?

Move from the guide into direct help for WordPress errors, unstable updates, maintenance gaps, and urgent rescue work.

Request WordPress support Explore the WordPress hub
Link copied to clipboard!