PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

Did your WordPress website run into the PHP Fatal error ‘Allowed memory size of 134217728 bytes exhausted’?

Did you get loading errors 500 from time to time without any noticeable reasons or did the wp staging push/pull process just stopped?

This can happen if there is not enough memory assigned to PHP or if the memory consumption of your WordPress Installation is limited.

Quick solution:

Increase WordPress Memory Limit

Try first increasing the WordPress Memory Limit.

Open the file wp-config.php and paste the code below just before the line that says ‘That’s all, stop editing! Happy blogging.’:

define( 'WP_MEMORY_LIMIT', '256M' );

Now, check again if your memory errors are resolved.

If this does not resolve your WordPress / PHP memory issues follow the advice below:

How to fix the Memory Exhausted Error?

First of all, check out how much memory is assigned to PHP and look at the system info log. Your Theme Tab > System Info to do so:

This should be at least 128M or better 256M or higher.

A more precise alternative is to create an empty file and add the code below into it:

Save the file as info.php and upload it to the root of your website via FTP or a file manager plugin.

Now open and find the line memory_limit

This line tells you the exact amount of memory in megabytes your site uses.

For medium WordPress sites, this memory limit should be at least 128M or better 256M.

If the memory limit is lower you need to raise it. You can raise the PHP memory limit by editing the PHP.ini. Open the PHP.ini and find the line memory_limit and change the value to:

memory_limit = 256M

Please ask your hosting provider where you can find the PHP.ini.

If you have no access to that file you can try to edit your .htaccess file and add the code below to it:

php_value memory_limit 256M

Now, open the file info.php or the system info log again and check out if the memory limit has been increased.

If you were successful and phpinfo() shows the correct memory_limit  start again WP Staging and the ‘Allowed memory size exhausted’ error should be solved and gone.

If you are still not able to increase the memory limit please ask your hosting provider if they can do it for you.