Table of Contents

Share:

How to Fix WordPress “Allowed Memory Size of Bytes Exhausted”

23/02/2020

allowed memory exhausted error

Among the most common issues that developers using PHP tend to run into are out-of-memory errors. This is especially true with online apps that need to process large amounts of data, which tend to quickly exhaust the limited memory that PHP’s default settings allot.

The good news for those using PHP with WordPress is that it’s fairly simple to tweak your site’s settings and give it more resources to use. Below, we go into details of the potential causes of this type of error, as well as offering seven quick fixes you can use to make sure your WordPress site is running with no problems.

What causes the error?

The most common phrasing of the error offered by WordPress is “fatal error: allowed memory size of 67108864 bytes exhausted”.

Even though the language used makes it sound quite serious, in this case, ‘fatal error’ simply means your PHP scripts don’t have enough memory to execute properly.

For those unfamiliar, WordPress is built using the PHP programming language. Like in any other programming language, scripts are simply chunks of code that determine how your site will behave given a certain input or instruction.

If WordPress tries to execute a script that takes more than the allowed amount of memory, the site will display the error message.

The error message itself can serve as an indicator of how much memory you are allowed to use by default:

  • 8 MB – PHP: Fatal Error: Allowed Memory Size of 8388608 Bytes Exhausted
  • 16 MB – PHP: Fatal Error: Allowed Memory Size of 16777216 Bytes Exhausted
  • 32 MB – PHP: Fatal Error: Allowed Memory Size of 33554432 Bytes Exhausted
  • 64 MB – PHP: Fatal Error: Allowed Memory Size of 67108864 Bytes Exhausted
  • 128 MB – PHP: Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted
  • 256 MB – PHP: Fatal Error: Allowed Memory Size of 268435456 Bytes Exhausted
  • 512 MB – PHP: Fatal Error: Allowed Memory Size of 536870912 Bytes Exhausted
  • 1 GB – PHP: Fatal Error: Allowed Memory Size of 1073741824 Bytes Exhausted

Taking the most frequent “fatal error: allowed memory size of 67108864 bytes exhausted” error message into account, this indicates that most servers allow you to use 64 MB of memory for your PHP scripts.

Potential fixes

There is, of course, a reason that servers only allow for a limited memory use – preventing poorly coded scripts from using up all the available server memory. In practice, a limit of 32 or 64 MB should be enough to cover all your needs.

On the other hand, if your limit is set to 128 MB and you find your site regularly exceeding it, you may be dealing with a faulty plugin.

The solutions below shouldn’t take more than a couple of minutes to implement and will help you both raise the memory limit for your WordPress site and remove any scripts taking up too much memory.

Fix 01: Edit wp-config.php

This should be the first thing you try, and in many cases, it should immediately fix the issue. It’s also worth noting that the following two solutions are simply variations of the fix detailed below:

  1. Connect to your WordPress site using an FTP client of your choice.
  2. Open your WordPress site’s root folder. Here, you need to find wp-config.php.
  3. Open wp-config.php and paste the following bit of code before the line saying ‘That’s all, stop editing! Happy blogging.’:
wp-config.php
  1. Save the changes to wp-config.php and re-upload it to your server.

As you can see from the code, this solution effectively fixes the issue by raising the allowed memory to 256 MB. Please note that certain web hosting providers don’t allow you to manually set the memory limit.

If this is the case, you will have to contact your service provider and have them allow for more memory on their end, or maybe upgrade your hosting package.

Fix 02: Edit PHP.ini

Try the following method if you can access your PHP.ini file:

  1. Log in to cPanel.
  2. Find and open the File Manager.
  3. Find and open the PHP.ini file by clicking on ‘Code Editor’ at the top of the screen. You can usually find it in the public_html folder.
  4. Raise the memory_limit setting by changing the code to:
memory_limit
  1. Make sure your PHP.ini settings are recursive, then try to access your site again and check if the issue is resolved.

Fix 03: Edit .htaccess

If, for some reason, you don’t have access to the PHP.ini file, you can still affect it indirectly by adding a bit of code to the .htaccess file:

  1. Log in to cPanel.
  2. Find and open the File Manager.
  3. Find and open the .htaccess file by clicking on ‘Code Editor’ at the top of the screen. You can usually find it in the public_html folder.
  4. Add the following code to .htaccess:
Edit .htaccess
  1. Reload your site to make sure the issue is resolved.

Fix 04: Using cPanel

Sometimes, the issue of memory doesn’t stem from server limits, but from the version of PHP your WordPress site is using. When using cPanel, going to the Software section will show you which version of PHP you are using.

Updating from version 5.4 to 5.6 will let you use the ‘Switch To PHP Options’ link on the right-hand side of the screen. Here, you can change the memory_limit setting to any value you want.

Fix 05: Using the Command Line

While this process is usually faster than using FTP, most hosting services won’t provide users with shared hosting plans with Secure Shell Access (SSH), which is crucial for this method to work.

This means you will be able to use this method only if you have a plan like a Virtual Private Server (VPS), or something similar that gives you full access to the server.

Use the following steps to access and change wp-config.php using the command line:

  1. Connect to an SSH client. For Windows users, PuTTY is a good choice.
  2. Use the SSH access credentials provided by your host service to log onto your SSH client.
  3. A command line will appear, prompting you to enter your username and password. Logging in will give you full access to the server using the command line.
  4. In the command line, enter the following:
wp-config.php
  1. You will see the wp-config.php file open using the Nano editor. Add the following code before the line saying ‘That’s all, stop editing! Happy blogging.’:
wp-config.php file
  1. Close the Nano editor by pressing Ctrl+X. Make sure you save the changes you made.

Fix 06: Using Xdebug

All of the fixes above were focused on solving the more immediate symptom of the out.of-memory error – namely, your site is not working. And while increasing the memory limit might get your site to run again, it doesn’t solve the root cause of the problem.

For this, you will need to take a more detailed look at your code.

For this method, we recommend using dedicated debugging software, such as Xdebug, which we will use in this example. You can install Xdebug by using packaging managers (port, yum, apt-get, and Homebrew), a pre-built binary, or simply compiling it yourself.

After installing Xdebug and refreshing your site page, you will notice that the error message is now a lot more informative. It will now tell you the exact file path and line number where the script stopped.

To get even more details, generate a ‘trace file’ by setting xdebug.auto_trace and xdebug.show_mem_delta config directives to 1.

Start from the bottom and work your way up the trace file. The deltas are shown in bytes, so look for ones with large numbers to find the ones taking up the most memory. When you are finished, be sure you set xdebug.auto_trace back to 0.

Debugging the scripts is simply preparation for the following method, which is aimed at fixing the actual cause of the issue…

Fix 07: Find the cause in the code

If you followed the methods above, by now you should be well equipped to cut to the root of the issue in the root and take care of the scripts taking up too much memory.

Doing this will not only help prevent the problem from popping up in the future but will also streamline the performance of your site and make for shorter loading times.

A useful rule of thumb is that, if you had to increase your memory limit to 128 MB or above, your code is already taking too much memory and should be reviewed.

Aside from the code itself, a good first place to look is the plugins. Faulty plugin coding, especially after major updates, can take up all the available memory, leaving none for the site itself. Another potential source could be your currently active theme, for much of the same reasons.

Finally, consider using a memory usage tracker. Ironically, a plugin like TPC! Memory Usage can prove to be a very effective tool for tracking and managing how much memory is used and for what.

Conclusion

Hopefully, the guide we provided will help you resolve any memory issues you encounter while using WordPress. While the quick fixes of increasing the available memory limit will work in most cases, it would be much better in the long term if you take the time to carefully analyze your code and find the scripts causing the issue.

This will not only make your site more stable but also improve overall performance and user experience.

FAQ

What does the “Allowed Memory Size of Bytes Exhausted” error mean in WordPress?

This WordPress PHP fatal error means a script exceeded the PHP memory limit while running. When a plugin, theme, or core process needs more RAM than your server allows, PHP stops execution, and WordPress shows “Allowed Memory Size of Bytes Exhausted,” often at 64MB.

How can I quickly increase the WordPress PHP memory limit?

The fastest fix is raising WP_MEMORY_LIMIT in wp-config.php to allocate more resources for PHP scripts. If your host blocks manual changes, you may need to adjust memory_limit in PHP.ini, .htaccess, or request a hosting upgrade to increase the PHP memory limit.

Why can a faulty WordPress plugin trigger memory exhaustion?

A poorly coded or recently updated plugin can allocate excessive memory during requests, cron tasks, or admin actions. If your site only breaks after installing or updating a plugin, the “Allowed Memory Size” error often points to plugin memory leaks or inefficient PHP operations.

When should I debug instead of just raising the memory limit?

If you’ve increased the limit to 128MB or higher and the error keeps returning, the root cause is likely inefficient code. Debugging with Xdebug can reveal the exact file path, line number, and memory delta so you can fix the script, not just the symptom.

Which hosting and server settings commonly affect WordPress memory usage?

Shared hosting plans often enforce strict PHP memory_limit values, limit SSH access, and restrict PHP.ini edits. Server configuration, PHP version, and available resources also impact WordPress performance, so switching PHP versions in cPanel or upgrading to a VPS can stabilize memory usage.

About the author

Nickey is Founder & CEO at NPSEO. He is currently focused on the company's systems and growth. Besides his passion for SEO, he is also passionate about WordPress and attending WordCamps. In his free time, Nickey enjoys good books, going to the gym, and spending time with friends.

Join our newsletter

We’ll send you a nice letter once per week. No spam.

Read more

Related posts

why does my business not show up on google maps

Why Does My Business Not Show Up on Google Maps?

Not showing up on Google Maps can cost you a lot in foot traffic and sales. Google Maps has over a billion monthly users, and nearly 90% of people use

Nickey Pickorita

27/03/2026

google my business posts

Google My Business Posts: Best Practices & Examples

Google My Business (GMB) posts, also known as Google Business Profile (GBP) posts, are a useful tool for businesses. It allows you to directly engage with customers, promote offers, and

Nickey Pickorita

27/03/2026

google my business photos

Google My Business Photos: Size, Tips & Best Practices

Google Business Profile (GBP) listings speak a thousand words. They humanize your business and make it relatable, which builds trust and drives engagement. Consequently, profiles with photos get 42% more

Nickey Pickorita

27/03/2026