Allowed Memory Size Exhausted in WordPress: How to Fix It
Getting an allowed memory size exhausted fatal error in WordPress? Raise the limit safely, then find and fix the plugin actually causing it.

“Allowed memory size exhausted” means PHP hit its memory limit while WordPress was trying to run, and it stopped the page rather than let the server run out of resources entirely. The fix is almost always a one-line change plus finding what is actually using the memory. This guide covers both, in the order that fixes it fastest.
The exact message usually looks like Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate ... bytes). The number in bytes is your current PHP memory limit; 134217728 bytes is 128MB, which is a common default on shared hosting.
Back up wp-config.php before editing it
Every fix below involves editing a file or a setting. Download a copy of
wp-config.phpfirst so you can restore it instantly if a typo causes a different error.
The quick fix: raise the WordPress memory limit
Open wp-config.php in the root of your WordPress install and add this line above the comment that says “That’s all, stop editing! Happy publishing.”:
define( 'WP_MEMORY_LIMIT', '256M' );
This raises the limit WordPress itself requests for the front end of your site. For the admin area, which often needs more when saving large pages or running plugin updates, add a second line:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Save the file and reload the page. If the error is gone, you are done for now, but keep reading, because a memory limit that keeps needing to go up usually means something is using far more than it should.
Check your current PHP memory limit
WordPress can only raise the limit up to what your hosting account’s PHP configuration allows; it cannot exceed the server-level limit set by your host. Check your actual limit under Tools → Site Health → Info → Server in wp-admin, next to “PHP memory limit”.
| Where the limit lives | How to change it |
|---|---|
wp-config.php | WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT constants (shown above) |
PHP itself (php.ini) | Edit directly if you have access, or via your hosting panel’s PHP settings |
.htaccess (Apache only) | php_value memory_limit 256M |
| Hosting panel (cPanel, Plesk, managed hosts) | A “Select PHP Version” or “PHP Configuration” screen, often with a slider or dropdown |
If your host caps the account at a low limit and support will not raise it, that is a sign the hosting plan itself has outgrown your site.
Find what is actually using the memory
Raising the limit treats the symptom. If the same page keeps needing more and more memory over time, something is consuming far more than a normal WordPress request should. The usual suspects, roughly in order of how often we see them:
- A single plugin doing heavy work on every page load, such as a page builder rendering large layouts, a backup plugin running mid-request, or an import tool processing a big file.
- A memory leak in a poorly coded theme or plugin that keeps allocating memory without releasing it during a long-running task.
- Very large images being processed or resized on the fly rather than served pre-optimised.
- Too many plugins active at once, each adding a small amount that adds up on a busy page.
Use WP_DEBUG to see where memory is exhausted
Turn on debug logging temporarily to see which file and line triggered the fatal error. Add these lines to wp-config.php:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );
Reproduce the error, then open wp-content/debug.log and look at the last fatal error entry. It names the exact file and function that ran out of memory, which usually points straight at the plugin or theme responsible. The PHP manual’s page on the memory_limit directive explains how PHP enforces this setting if you want the underlying detail. Turn debug mode off again once you are done, since leaving it on can expose file paths to visitors.
Isolate the plugin or theme causing it
With the culprit file in hand, deactivate plugins one at a time, starting with the one named in the log, and reload the page after each. If the error only appears with a specific plugin active, that plugin needs updating, replacing, or reporting to its developer with the debug log attached.
If the log points at a theme file, switch temporarily to a default theme such as Twenty Twenty-Five to confirm the theme is the cause before you decide whether to fix or replace it. The same plugin-by-plugin approach is worth knowing generally, since it is also how you track down a WordPress white screen of death when no error message shows at all.
Reduce memory usage instead of just raising the limit
- Deactivate and delete plugins you are not actively using; each one loads code on every request even if you never see its output.
- Switch heavy tasks like large imports, exports and bulk edits to WP-CLI, which runs outside the web server’s PHP limit and can be given its own memory allocation.
- Resize large images before uploading rather than relying on WordPress to shrink them on every page load.
- Add object caching, such as Redis or Memcached if your host supports it, which reduces repeated database work that adds to memory pressure on busy pages.
Increasing memory for WP-CLI and cron tasks
Command-line imports and scheduled tasks sometimes hit their own separate memory limit even after you raise WP_MEMORY_LIMIT for the website. For WP-CLI, pass a higher limit directly:
php -d memory_limit=512M wp import large-file.xml --authors=create
For WP-Cron tasks that time out or run out of memory, check whether your host lets you configure a separate PHP memory limit for CLI or cron processes, since it is sometimes set lower than the web-facing limit by default.
Preventing the allowed memory size exhausted error long term
Keep plugins, themes and PHP itself updated, since memory leaks are often fixed in later releases once developers spot them. Review your active plugin list every few months and remove anything you no longer use. The WordPress wp-config.php reference documents every memory-related constant if you want the full detail beyond what is covered here. A memory exhaustion error is one specific cause of the broader WordPress 500 internal server error, so if the message on screen is more generic than “allowed memory size exhausted”, that guide covers the other common causes too.
Rather have it fixed for you?
We fix the allowed memory size exhausted error and other WordPress fatal errors from $45, usually the same day, and tell you which plugin or theme caused it. Get your website error fixed.
Allowed memory size exhausted: quick answers
Why does the allowed memory size exhausted error come back after I raise the limit?
Because raising the limit treats the symptom, not the cause. If a plugin has a memory leak or does unusually heavy work, it will eventually hit whatever new limit you set. Find the cause with WP_DEBUG rather than repeatedly raising the number.
Can I set the memory limit too high?
Setting it far above what your server actually has available will not cause harm on its own, since PHP only uses what a request needs, but your host’s real server-level limit still applies regardless of what you set in wp-config.php.
Does allowed memory size exhausted mean my hosting plan is too small?
Sometimes, especially if every plugin is well maintained and the site is busy, but often the real cause is one misbehaving plugin rather than genuinely needing more resources. Check the debug log before assuming you need to upgrade hosting.
Is 256M enough for WP_MEMORY_LIMIT?
For most WordPress sites, yes. Sites with a page builder, WooCommerce, and several active plugins sometimes need 512M for the admin area specifically, set via WP_MAX_MEMORY_LIMIT, while the front end usually needs far less.



