How to Increase WordPress Memory Limit: 4 Methods

Are you having problems with your 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/smartwp.co/wp-includes/plugin.php 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 256 MB. 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.

<?php
define('WP_MEMORY_LIMIT', '256M');

By default, the WordPress memory limit is 32 MB.


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;

Trying to find your server’s php.ini file? You can use the phpinfo() function to find your server’s php.ini location.


Increase the PHP Memory Limit using .htaccess

You can also use your WordPress site’s .htaccess file to modify the PHP memory limit. Adding the ‘php_value memory_limit’ line to your .htaccess file will modify your site’s PHP memory limit.

php_value memory_limit 256M
view raw .htaccess hosted with ❤ by GitHub

Likely you’ll need to reset apache after modifying this value. Additionally like other methods on this list your web host can disable this from functioning.


Ask Your Host for Help

If you don’t have access to either of these files, then the best option is to contact your hosting provider and ask them to increase the memory limit. Most hosting providers will be happy to do this for you.

It’s also worth mentioning that some hosting providers may have their own control panel where you can adjust the memory limit without having to edit any files. Check with your hosting provider to see if this is an option.


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 the code on your site or something your web host has implemented.

Picture of 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.