Listen to this article
9 minute listen
Narrated by an AI voice · 8 chapters
AI Overview
"Fatal error: Allowed memory size of 134217728 bytes exhausted" means a PHP process on your WordPress site ran out of memory. Raise WP_MEMORY_LIMIT in wp-config.php, check the PHP memory_limit your host allows, and find the plugin or task that needs so much memory.
Key takeaways
- The error means a PHP request used more memory than allowed; 134217728 bytes in the message is a 128 MB limit.
- Add WP_MEMORY_LIMIT 256M to wp-config.php first; the PHP memory_limit set by your host caps what WordPress can use.
- Check both limits in Tools > Site Health > Info under Server and WordPress Constants.
- If 256 MB is not enough, a plugin or task is too heavy: check what changed and read the error log.
- Monitoring important pages catches memory errors that break checkout or one page while the home page looks fine.
Free WordPress plugin
Know which plugin update broke your site.
The free MyKavo plugin watches your site through every plugin, theme and core update, and tells you which one caused a change, before your visitors find it.
- Records every plugin, theme and WordPress update
- Checks your key pages right after each update and names the one that broke something
- One-click rollback when an update goes wrong, free
- Changes, alerts and before-and-after proof inside wp-admin
Free on WordPress.org · WordPress 6.2+ · PHP 7.4+ · The check after each update comes with every paid plan
Summarize with AI
Opens the assistant in a new tab with a link to this post.
On this page
"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)" is one of the most searched WordPress errors. It can take down a single page, break wp-admin, or turn your whole site into the "There has been a critical error on this website" message.
The good news: it is usually quick to fix. This guide explains what the error means, how to raise the WordPress memory limit safely, and how to find what is using so much memory in the first place.
What the error means#
Every time someone opens a page, PHP runs WordPress, your theme and your plugins. PHP gives each request a fixed amount of memory. When a request needs more than that, PHP stops it and logs the fatal error.
The number in the message is the limit in bytes:
- 33554432 bytes is 32 MB
- 67108864 bytes is 64 MB
- 134217728 bytes is 128 MB
- 268435456 bytes is 256 MB
So "Allowed memory size of 134217728 bytes exhausted" means the request hit a 128 MB limit.
Two limits: WordPress and PHP#
There are two settings, and the lower one wins.
- PHP memory_limit is set by your host in the server configuration. WordPress can never use more than this.
- WP_MEMORY_LIMIT is the amount WordPress asks for. By default it is 40 MB on a single site and 64 MB on multisite, and WordPress raises it automatically if PHP allows more. In wp-admin, WordPress uses WP_MAX_MEMORY_LIMIT, which defaults to 256 MB.
You can see both in Tools > Site Health > Info: the PHP memory limit is under Server, and WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT are under WordPress Constants. Our WordPress Site Health guide explains the rest of that screen.
How to fix it#
1. Raise WP_MEMORY_LIMIT in wp-config.php#
Open wp-config.php in the root folder of your site with your host's file manager or SFTP. Above the line that says "That's all, stop editing", add:
define( 'WP_MEMORY_LIMIT', '256M' );
If the error only happens in wp-admin, for example while importing or editing a large page, you can also add:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Save the file and reload the page. If the error is gone, you are done. If nothing changed, PHP's own limit is lower and is still capping WordPress.
2. Raise the PHP memory_limit#
How you change the PHP limit depends on your host:
- Hosting panel. Most hosts have a PHP settings screen. In cPanel it is MultiPHP INI Editor or Select PHP Version > Options. Set memory_limit to 256M.
- php.ini or .user.ini. On some hosts you can add memory_limit = 256M to a php.ini or .user.ini file in the site's root folder.
- .htaccess. On Apache servers running PHP as a module, php_value memory_limit 256M works. On most modern hosts (PHP-FPM, LiteSpeed, Nginx) this line does nothing or causes a 500 error, so remove it if the site breaks.
- Ask your host. Managed and shared hosts often have a hard ceiling. Support can tell you the maximum and raise it if your plan allows.
256 MB is plenty for almost every WordPress site. If a site still runs out at 256 MB or 512 MB, raising it further only hides a problem.
3. Find what is using the memory#
A normal page on a normal site uses far less than 128 MB. If you hit the limit, something is heavy. Common causes:
- A plugin doing too much on every page load, such as a page builder, an analytics plugin storing data on each visit, or a poorly written plugin.
- Large imports and exports, for example WooCommerce product imports or backup plugins zipping the whole site.
- Image processing of very large uploaded photos.
- A plugin conflict or loop after an update.
To narrow it down, check when the error started. If it appeared right after a plugin, theme or PHP update, that change is the first suspect. Deactivate the most recent plugin and test again. If you cannot reach wp-admin, rename the plugin's folder in wp-content/plugins over SFTP to disable it. Our plugin conflict guide walks through testing plugins one by one.
The PHP error log, or WordPress's own debug.log with WP_DEBUG_LOG enabled, shows the file that was running when memory ran out. That file usually points straight at the plugin or theme involved.
4. Check your PHP version#
Old PHP versions use more memory and run slower. If your site is on an outdated PHP version, upgrading often reduces memory use. Our WordPress PHP version guide explains how to check and upgrade safely.
Free WordPress plugin
Update WordPress without the guesswork.
The free MyKavo plugin watches your site through every plugin, theme and core update, and tells you which one caused a change, before your visitors find it.
- Records every plugin, theme and WordPress update
- Checks your key pages right after each update and names the one that broke something
- One-click rollback when an update goes wrong, free
- Changes, alerts and before-and-after proof inside wp-admin
Free on WordPress.org · WordPress 6.2+ · PHP 7.4+ · The check after each update comes with every paid plan
When the error shows a critical error page#
Since WordPress 5.2, a fatal error usually shows "There has been a critical error on this website" instead of the raw message, and WordPress emails the admin a recovery link. That email often names the plugin or theme that caused the problem. See how to fix the critical error for the recovery mode steps.
How to prevent it#
- Set a sensible limit of 256M once, so normal growth does not break the site.
- Remove plugins you do not use, and avoid running two plugins that do the same job.
- Test updates on a staging site before applying them to a busy site.
- Keep PHP current within what your theme and plugins support.
- Monitor the site, so a memory error on an important page is noticed in minutes, not days.
Catch it before your visitors do#
A memory error often affects only some pages: checkout, a large product page or a page built with a heavy builder. Visitors see an error while the home page looks fine. MyKavo checks your important pages on a schedule and alerts you when one starts returning errors or looks different, with before and after screenshots. The free MyKavo WordPress plugin also records plugin, theme, core and PHP changes, so you can see what changed right before the error started.
Frequently asked questions#
Frequently asked questions
What does "Allowed memory size exhausted" mean in WordPress?
A PHP request ran out of the memory it is allowed to use. The number in the message is the limit in bytes, for example 134217728 bytes is 128 MB. WordPress stops the request and shows an error or a critical error page.
How do I increase the WordPress memory limit?
Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above the "That's all, stop editing" line. If that does not help, raise PHP's memory_limit in your hosting panel, php.ini or .user.ini, or ask your host, because the PHP limit caps what WordPress can use.
What is a good memory limit for WordPress?
256 MB is enough for nearly every site, including WooCommerce stores. If a site still runs out at 256 MB or 512 MB, a plugin or task is using far too much memory and should be fixed rather than given more.
Where can I see my current memory limit?
In wp-admin go to Tools > Site Health > Info. The PHP memory limit is under Server and WP_MEMORY_LIMIT is under WordPress Constants.
Why does the memory error happen only on some pages?
Different pages do different work. A checkout, an import screen or a page built with a heavy page builder can need much more memory than the home page, so it can fail while the rest of the site works.
Can a plugin cause the memory limit error?
Yes, it is the most common cause. A plugin that loads too much data, runs large imports or has a bug can use all the available memory. Disable recently updated plugins first and check the error log to see which file was running.
Write for MyKavo
Know website monitoring, WordPress or SEO from real work? Pitch us a guide. You keep a byline with one link to your site. Read the guidelines
Get alerted when your site breaks. Free, no card.
Start free