Introduction
Sooner or later, many WordPress sites hit a wall that reads something like: “Fatal error: Allowed memory size of 134217728 bytes exhausted.” It usually appears after installing a new plugin, importing content, or running a heavy task — and it can take down a single page or your whole site. The cause is simple: WordPress asked for more memory than your server allows it to use. The fix is usually just as simple: give it a little more, or find what’s using too much.
What the Memory Exhausted Error Means
Every PHP process on your server has a memory limit — a cap on how much RAM a single request can use. WordPress, your theme, and your plugins all draw from that budget. When a task needs more than the cap allows, PHP stops it cold and throws the “allowed memory size exhausted” error rather than letting one request consume the whole server.
The number in the message is your current limit in bytes — for example, 134217728 bytes is 128 MB. Many hosts set this fairly low by default, which is fine until a plugin or operation needs more.
Step 1: Increase the WordPress Memory Limit
The most direct fix is to raise the limit. Open wp-config.php in your site’s root folder and add these lines just above /* That’s all, stop editing! */:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WP_MEMORY_LIMIT sets the limit for the front end; WP_MAX_MEMORY_LIMIT raises it for memory-heavy admin tasks like media processing. Save the file and reload — for many sites, this alone resolves the error.
Step 2: Raise the Limit at the Server Level (If Needed)
Some hosts cap PHP memory at the server level, which overrides wp-config.php. If the error persists, try one of these (depending on what your host allows):
- php.ini — set
memory_limit = 256M. - .htaccess — add
php_value memory_limit 256M(works on some Apache setups). - Hosting control panel — many panels have a PHP settings page where you can raise the memory limit directly.
If none of those are available or they’re locked, a quick support ticket asking your host to raise memory_limit usually does the trick — most will accommodate a reasonable request.
Step 3: Find What’s Eating Your Memory
Raising the limit treats the symptom, but if a single plugin is burning through hundreds of megabytes, that’s worth knowing. To identify the culprit, temporarily deactivate your plugins — via wp-admin if you can reach it, or by renaming /wp-content/plugins over FTP if you can’t — then reactivate them one at a time, watching for when the error returns. The plugin that brings it back is your memory hog; update it, replace it, or raise the limit enough to accommodate it.
Turning on debugging can help pinpoint exactly where memory runs out. Add define( 'WP_DEBUG', true ); and define( 'WP_DEBUG_LOG', true ); to wp-config.php, then check /wp-content/debug.log for the file and line that triggered the error.
When It Happens During a Specific Task
Sometimes the error only appears during one heavy operation — importing a large file, building a big page, or running a backup — rather than on normal page loads. In that case, the real fix is to make that task work within your memory budget rather than just raising the ceiling forever. For backups specifically, processing the site in small chunks avoids loading everything into memory at once; see how chunked processing prevents backup failures on shared hosting.
If the Error Blocks Your Whole Site
A fatal memory error during a critical operation can leave your site unreachable — sometimes even wp-admin. If you can’t get in to deactivate the offending plugin, you have two reliable ways back: restore a recent backup, or use Emergency Recovery to roll back without logging in at all. And if the trouble started right after an update, an automatic before-update backup gives you a clean snapshot to return to.
Related WordPress Errors
- 500 Internal Server Error — memory exhaustion sometimes surfaces as a generic 500.
- The White Screen of Death — a blank page is often a fatal error like this one.
- Error Establishing a Database Connection — if the failure is the database rather than memory.
Frequently Asked Questions
What should I set the memory limit to?
256 MB is a safe, comfortable value for most sites. Going higher rarely hurts, but if you find you need 512 MB or more just to load normal pages, a plugin is likely the real problem.
I added WP_MEMORY_LIMIT but nothing changed — why?
Your host is probably enforcing a lower limit at the server level, which overrides wp-config.php. Raise it via php.ini or your control panel, or ask your host.
Is a higher memory limit a security or performance risk?
No. It simply lets a request use more RAM when needed. The only real downside is masking a plugin that’s genuinely misbehaving — which is why Step 3 is worth doing.
Could this happen during a backup?
It can on plugins that build the whole archive in memory. A backup tool that works in small chunks avoids the problem entirely, even on low-memory shared hosting.
Conclusion
The WordPress memory exhausted error sounds severe, but it’s really just your site asking for more room than the server currently allows. Raise the limit in wp-config.php, lift it at the server level if needed, and track down any plugin that’s using far more than its share. With a sensible limit and a recent backup in place, this error goes from a site-down emergency to a quick, routine fix.
A fatal error shouldn’t mean a lost site
With automatic backups from Nota Backup & Restore, even a site-breaking error is a quick restore — and you can recover without logging in. Start your 14-day free trial — no credit card required.
