Skip to main content
All CollectionsTroubleshooting and FAQsCommon Issues
How to Fix the PHP Memory Limit Error
How to Fix the PHP Memory Limit Error

The PHP Memory Limit Error occurs when a PHP script tries to use more memory than the server allocates by default.

Updated over 6 months ago

Encountering a PHP Memory Limit Error in WordPress can disrupt your website's functionality and prevent you from performing essential tasks. This error typically occurs when your site exceeds the allocated memory limit set by your server.

In this article, we will guide you through the process of diagnosing and fixing the PHP Memory Limit Error.

Note: This troubleshooting guide may require that you make server-side changes to your website. If you are uncomfortable making those changes, you should contact your hosting provider for assistance.

Memory_limit is a PHP configuration directive that sets the maximum amount of memory (in bytes) a script can use. The error that gets outputted can look like this:

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate x bytes) in /path/to/script

or like this:

PHP Fatal error: Out of memory (allocated X) (tried to allocate Y bytes) in /path/to/script

Increase the PHP Memory Limit in WordPress

  1. Use an FTP connection, the hosting File Manager app, or the Advanced File Manager plugin to access your website's files

  2. Edit the wp-config.php file located in your WordPress root directory and before this line of code:

    That’s all, stop editing! Happy blogging.

    Add this line of code:

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

Note: For most websites, a 128M limit is enough, but if that doesn't work out in your case, you can increase it.

Increase the PHP Memory Limit using the PHP configuration file (php.ini)

This is usually located in the root hosting directory or in your WordPress install directory. Sometimes, the file must be generated from your hosting's cPanel or created manually in the WordPress install directory. 

  1. Use an FTP connection, the hosting File Manager app, or the Advanced File Manager plugin to access your website's files

  2. Open the php.ini file

  3. Include the following line of code at the bottom of the file:

    memory_limit = 256M

Note: Some hosting providers do not allow this value to be increased, or they have a global value set, which would require a special configuration. For these cases, the best advice would be to contact your hosting provider support for assistance.

Consider switching to Divi Hosting

We partnered with our favorite WordPress hosts to create the best hosting solution for Divi. The PHP limit is already sufficient on Divi Hosting, so you don't need to worry about receiving errors. Plus, Divi Hosting comes with Divi pre-installed and activated automatically.

Did this answer your question?