11 Mar 2019
If your WordPress site is hosted on a shared host, you might probably run into an error message saying the allowed memory size has been exhausted. This basically means that your server is out of memory. Web servers are pretty much the same as your computer - it needs memory to process the site. When it runs of memory, you end up seeing that error.
In this foundational tutorial, we will show you a simple solution to increase the PHP memory limit on your server, with a choice of 3 methods. We know that error messages can be annoying so check out this tutorial if you're also running into issues with WordPress being stuck in maintenance mode.
Before We Begin - Contact Your Hosting Provider First
You may want to contact your hosting provider before you begin because some hosts don't allow users to increase PHP memory. In some cases, only the host provider can change the PHP memory limit on the server. Ask your host provider what is the best way to change the PHP memory limit.
Method 1) Edit the wp-config.php file
With WordPress, you can change the memory limit by editing the wp-config.php file. First connect to your server with a FTP software or you can login to your cPanel and use the File Manager tool provided.
The wp-config.php should locate in the root folder where you have WordPress installed. Edit it and add the following line:
Method 2) Edit the php.ini file
If you have access to the php.ini file (note that some host providers don't give access to the php.ini file), you can locate the code for the memory limit and change it to 256 MB. The code would look like the image below:
memory_limit = 256M ; Maximum amount of memory a script may consume (64MB)
Method 3) Edit the .htaccess file
You can also edit the .htaccess file located in the root folder and add the following line of code to increase the PHP memory limit:
php_value memory_limit 256M
If you have tried all of the above and nothing has worked, contact your host provider about the issue. They might not allow users to change the PHP memory limit or might have a different way of doing things. But they will likely help work out the solution you need. Thanks again for reading!