How to fix WordPress Memory Exhausted Error

increasing the PHP memory limit
Rapidly Fixed WordPress Memory Exhausted Error

How can PHP memory be raised to fix the exhausted WordPress memory issue?

As a WordPress developer, have you ever run into an error in WordPress reading "Allowed memory size exhausted"? This is usually an issue that web developers have to see every day. What this error indicates is that your website is running out of memory for processing tasks. The good news is that increasing the PHP memory limit will enable you to fix it. We should proceed slowly here.

What causes the memory exhausted error?

WordPress uses PHP. Every action on your website uses some form of memory. Your server, however, has a specific restriction. Your site shows the exhausted memory error when it runs beyond what is allowed. This usually occurs under these circumstances:

  • You register a sizable plugin.
  • Upload your significant files.
  • Your theme or plugin uses significant scripts.

There are several ways to raise PHP memory in WordPress:

  •  Alter the wp-config.php file. This is the most basic approach.
  • Using FTP or File Manager, reach your website's root directory.
  • Look for the file named wp-config.php.
  • Include this code just before the line saying "That's all, stop editing."
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');
  • Save this day!
  • Reload your website today.

Your hosting might allow you to change 256M to a greater number, like 512 M.

These code changes may not function if your hosting server (like Hostinger, namecheap, GoDaddy, etc) have set the limits on memory via server files (php.ini or at even .htaccess). If the above code modifications do not work as expected, you may need to send a message to your hosting services provider.

  • You can also verify the current memory limit by installing a plugin like "Site Health" or a custom PHP info file on your WordPress website.

Edit the php.ini file if it exists

Some hosts allow you to edit php.ini file. Your php.ini file can be found either in the root or in a folder named "etc", which can be found at: /etc/php/{version}/apache2/php.ini

  • Change or add this line:

    memory_limit = 256M
  • Save the file and reboot your server if you have the right permissions to do so.

Edit the .htaccess file

If the above phases lead to failure, try this one. Modify .htaccess file located at your document root.

  • Add this line either at the top or the bottom:
php_value memory_limit 256M
  • Run a second test of your site after saving the file.
  • Still not working? Contact your hosting company.
  • Should any of the above approaches fail, your hosting service might be blocking memory changes. Reach out to them and ask that they raise the PHP memory limit for you.

If this sounds familiar, you may also want to read about 404 Errors on WordPress Posts we previously covered.

Conclusion

They can simply adjust the server settings on their end. Although it's annoying, the "Memory Exhausted" error in WordPress is usually easy to fix by editing the wp-config.php file. There's no need to stress—just follow the guidelines above to increase your memory limit. Your site will be running faster and more smoothly in no time.

 

Still not fixed, hire one of our team members who are professional wordpress developers. We will be happy to help you!

Related Solutions