How to Increase the Memory Limit on WordPress

The need to increase the Memory Limit on a WordPress website comes when errors like this appear:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 1258608 bytes) in /home/servername/public_html/wp-includes/plugin.php on line xxx

So, in order to fix this error you need to follow one of the next methods. There are multiple ways to fix it (by yourself or contacting your hosting providers). Most of the hosting providers will give you assistance and show you have to increase the memory limit. Many of our customers have problems with the memory limit and we decided to include this article in our WordPress Tutorials list.

Method 1 to increase the Memory Limit: Edit the wp-config.php file

Add this line at the end of your wp-config file. It is usually perfect if you place it on the spot in the screenshot below the code.

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


Method 2: Edit your php.ini file

If your website already has a php.ini file on its root, then you can simply edit it; otherwise if the server does not have the php.ini file, you can create it via the cPanel of your hosting or via FTP. Then, add this line at the end of the php.ini file:

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

Method 3: Edit your .htaccess file

.htaccess can be edited via FTP (File Transfer Protocol) or via cPanel. If you try to modify it from your cPanel, but the file isn’t visible on the file list, then most probably you need to enable the option to view hidden files.

The .htaccess is located next to the wp-includes folder, on the root of your site.


This line needs to be added into the .htaccess file in order to increase the Memory Limit;

php_value memory_limit 128M


Note: If you tried all of these three methods and neither of them changed the memory limit, then the last solution is your hosting provider. Most probably there is a limitation from them.

Leave a comment