What is the «Fatal error: Allowed memory size of X bytes exhausted» in WordPress?
The «Allowed memory size of X bytes exhausted» error means WordPress has exhausted the PHP memory limit assigned by your hosting. It’s fixed by increasing this limit (usually to 256 MB or 512 MB) in wp-config.php, php.ini, or .htaccess, or by identifying the plugin or theme consuming all available memory.
Published on · 7 min read

You wake up one day, open your WordPress site, and find a blank screen or a message straight out of a horror movie: «Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)». You can’t access the dashboard, you can’t publish, and you don’t know what happened.
Take a deep breath. This error doesn’t mean you’ve lost your content. It means WordPress tried to use more memory than your server allows. And in most cases, it has a relatively simple fix.
Quick answer: The error indicates that the PHP memory_limit has been exceeded. The fastest solution is to add define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php. If the problem persists, the culprit is usually a poorly optimized plugin or theme consuming all the memory.
What this error exactly means
WordPress is built on PHP, and PHP has a RAM limit it can use to run each script. That limit is called memory_limit and it’s set by your hosting provider (or by you, if you have access to the server configuration).
When WordPress, a plugin, or a theme tries to process more data than fits into that limit, PHP stops dead in its tracks and throws the fatal error. It’s like trying to put 5 liters of water into a 2-liter bottle: the system can’t handle it and warns you.
The most common limits on shared hosting are 128 MB or 256 MB. For projects with many plugins, high traffic, or large imports, 256 MB may fall short and you should consider bumping it to 512 MB.
The most common causes
Having audited over 40 projects, I can tell you this error rarely appears by chance. These are the most frequent reasons behind it:
A plugin or theme consuming too much memory
This is the number one cause. Some Page Builder plugins (Elementor, WPBakery), backup plugins, security plugins, or data import tools can consume hundreds of megabytes in a single request. If the error appears right after installing or updating something, suspect that first.
Hosting memory limit set too low
Many cheap hostings set a memory_limit of 64 MB or 128 MB. For a modern WordPress site with several plugins, that’s insufficient. If your project has grown and you’ve never touched this setting, you’ve likely hit the ceiling.
Heavy tasks: imports, backups, or updates
Importing a large CSV, restoring a backup, or updating a theme with many files can spike memory usage temporarily. In those cases, the error only appears during that specific task, not permanently.
Infinite loop or poorly written code
Less frequent, but possible. A plugin or custom code snippet can enter a loop that never ends, consuming memory until it runs out. In this case, the error is usually accompanied by a CPU spike on the server.
Outdated WordPress or obsolete PHP
Older versions of WordPress and PHP aren’t optimized for current workloads. Keeping the core, themes, and plugins up to date is part of the solution—and part of prevention.
How to fix it step by step
I suggest a logical order: from the fastest, least invasive solution to the one that requires more diagnosis. Don’t skip steps.
Step 1 · Increase the limit in wp-config.php (the fastest way)
Access via FTP or your hosting’s file manager, open the wp-config.php file at the root of your WordPress installation, and look for the line that says /* That's all, stop editing! Happy publishing. */. Right before that line, add:
define( 'WP_MEMORY_LIMIT', '256M' );define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Save the file and reload your site. If the error disappears, you’re done. If your hosting has a hard cap (common on shared plans), you’ll need to contact their support to raise it.
Step 2 · Modify php.ini (if you have access)
If your hosting allows you to edit the php.ini file, look for the memory_limit directive and change it to 256M or 512M:
memory_limit = 256M
This method is more global and affects all PHP applications on your account. If you can’t find the file or don’t have permissions, move to the next step.
Step 3 · Use .htaccess (Apache only)
If your server runs on Apache and you can’t touch php.ini, you can add this line to the end of your .htaccess file:
php_value memory_limit 256M
Heads up: this method doesn’t work on all hostings and, if applied incorrectly, can cause a 500 error. If you test it and the site stops loading, remove the line and go back to step 1.
Step 4 · Identify the culprit plugin or theme
If you’ve increased the limit and the error persists or reappears, the problem isn’t a lack of memory—it’s a component consuming it disproportionately. Do this:
- Deactivate all plugins.
- Check if the error disappears.
- Reactivate the plugins one by one, testing the site after each activation.
- The last one you activate that breaks the site again is the culprit.
If the problem lies in the theme, temporarily switch to a default theme (Twenty Twenty-Four or Twenty Twenty-Five) and check if the error reproduces.
Step 5 · Contact your hosting provider
If you’ve tried everything above and the error is still there, it’s time to open a support ticket. Provide the exact message, the steps you’ve followed, and ask them to check the memory_limit on your account. In many cases, the hosting can raise it temporarily or permanently.
How to prevent it from happening again
This error rarely warns you. It shows up at the worst possible moment. These three measures drastically reduce the likelihood of running into it:
Keep WordPress, themes, and plugins updated
Updates don’t just fix vulnerabilities; they also optimize resource consumption. A serious WordPress maintenance plan is the best prevention.
Check your hosting’s memory limit
Before the error appears, check your hosting panel for the current memory_limit. If it’s at 128 MB, bump it to 256 MB. If your project is large, aim for 512 MB.
Don’t hoard unnecessary plugins
Every active plugin consumes memory. If you have 30 plugins, you’re multiplying the chances that one of them exhausts the limit. Review your plugin list from time to time and remove what you don’t use.
If you also want your WordPress to run fast and not run out of resources, check out my guide on how to speed up a slow WordPress. And if the error comes with other technical issues, such as the database connection error, take a look at that guide too.
Frequently asked questions about the «Allowed memory size exhausted» error
Have I lost my website content?
No. The error is a PHP execution failure and doesn’t affect the database or files. As soon as you increase the memory limit or deactivate the culprit plugin, everything will return to normal.
What memory value should I set?
For most websites, 256 MB is enough. If you have a large ecommerce site, many plugins, or perform massive imports, go up to 512 MB. Don’t set an arbitrarily high value if you don’t need it, as it can mask an underlying problem.
Can I increase the memory myself or do I need my hosting provider?
You can try with wp-config.php (method 1). If your hosting limits memory_limit at the server level, you’ll need to contact their support to raise it. On managed hostings, this is usually a common and quick request.
Does this error affect SEO?
Directly, no. It’s an admin dashboard error or an internal task that usually doesn’t affect the public site. However, if the error occurs on the frontend and the site stops loading for hours, Google may interpret that the site is unavailable and reduce crawling. Prevention is part of technical SEO.
Need help diagnosing your WordPress? If the error persists or you want to thoroughly review your site’s performance, you can check out my complete SEO audit in 7 steps or contact me directly. I’ll help you identify the cause and get your WordPress stable.
Does your WordPress throw technical errors?
I review your installation, detect memory, performance, and configuration issues, and get your site stable and ready to rank.