How to Increase WordPress Memory Limit

One common issue that can plague a WordPress site is the dreaded “PHP Fatal error: Allowed memory size of 26843546 bytes exhausted”. There are many reasons PHP may run out of memory in WordPress but typically it’s because you’re hitting PHP’s memory limit in your hosting environment. Luckily you can change WordPress memory limit with a variable in your wp-config.php.

So if you’re seeing a fatal PHP error like the one below you’re in the right place:

PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 12288 bytes) in /sites/ on line 584

Increase PHP Memory Limit in WordPress

To increase the PHP memory limit in WordPress you’ll need to be familiar with FTP and editing PHP files. Login to your server’s FTP so you can edit your site’s wp-config.php in the root of your WordPress install. Adding the snippet below will increase the memory limit to 256mb. This should be more than enough for most WordPress sites.

This snippet can be added before the line that says “Happy Blogging” in your site’s wp-config.php file.

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

By default the WordPress memory limit is 32mb.

Increase the PHP Memory Limit in PHP.ini

If the above doesn’t work you may need to edit your server’s php.ini file to increase your memory limit. This can be done by modifying the “memory_limit” line in your php.ini file.

memory_limit = 256M;

If none of these changes work to change your memory limit in WordPress you can also reach out to your web host for more help. There could be an issue with code on your site or something your web host has implemented.

Andy Feliciotti

Andy Feliciotti

Andy has been a full time WordPress developer for over 10 years. Through his years of experience has built 100s of sites and learned plenty of tricks along the way. Found this article helpful? Buy Me A Coffee

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Tips Monthly

Get the latest from SmartWP to your inbox.