PHP Memory Limit Error

The PHP Memory Limit Error will output when a PHP script is trying to use more memory than the server allocates, usually by default.

Vlad avatar
Written by Vlad
Updated over a week ago

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

memory_limit  is a PHP configuration directive that sets the maximum amount of memory (in bytes) that a script is allowed to 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

PHP Memory Limit in WordPress

WordPress configuration file (wp-config.php)

Open the wp-config.php file located in your WordPress root directory and just after the line:

That’s all, stop editing! Happy blogging.


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.

PHP configuration file (php.ini)

This is usually located in the root hosting directory or on your WordPress install directory. In some cases the file will need to be generated from your hosting's cPanel or created manually in the WordPress install directory. 

Once the php.ini file has been created/generated open it and include the following 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 and it would require special configuration. For these type of cases, best bet would be to reach out to the 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. On Divi Hosting, the PHP limit is already sufficient, 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?