Knowledge Base
Save up to  70% off.  Start your website today!

WordPress Fatal error: Allowed memory size exhausted

Memory allocation and exhaustion problems within WordPress installations.

By default, our servers allow up to 32MB of data to be transferred via PHP. Not having enough memory can result in errors that look similar to this one:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2515174 bytes) in /path/to/WordPress/file.php on line 1331 

Before we get started, it is important to understand which of the three PHP settings you are using for your hosting account. Please see PHP Configuration to learn how to check your PHP settings.

If using PHP7.4 (Single php.ini) or PHP7.4 (FastCGI), locate the "php.ini" file inside "public_html/" directory; for the standard PHP7.2 to 7.4 settings, make a copy of the php.ini file first and place it in the "wp-includes/" directory. If the php.ini file cannot be located, a new php.ini.default file can be created via the cPanel PHP Config icon. Be sure to rename the file to php.ini, and it will not function while named php.ini.default.

Note: PHP versions PHP 7.2 is deprecated. We recommend that you update to a supported version of PHP. For more information, you may visit this PHP documentation.

Within the php.ini file, modify the "memory_limit" value. The php.ini file can be edited with any text editor, including the "Edit" or "Code Edit" option within your Bluehost File Manager. With the file open, search for memory_limit by pressing this (ctrl+f). Here you should see the following line:

 memory_limit = 256M  ; Maximum amount of memory a script may consume (256MB)

Update this number to accommodate a higher amount of memory; we suggest setting the value as "64M," fulfilling the most common requirements. Be sure to save any changes. Next, open the file wp-settings.php (located within the directory where WordPress is installed). Near the top of this file, look for:

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

Update this value to the new memory limit as well. Save changes to the file. Once the file is saved, the effect should be immediate.

Note: To check and see that the memory_limit has been updated properly, create a new text file called info.php within the same directory you edited your new php.ini file. Create this new file and add the following code:

<?php phpinfo() ;?>

Then view this page in a browser (be sure to include the directory in the URL if you placed the info.php file). The PHP settings, including the memory_limit, should have changed. This will also show the path to the php.ini file, which is being used.

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.

Did you find this article helpful?

* Your feedback is too short