How to Resolve ‘Allowed Memory Size Exhausted’ Error in WordPress

How to Resolve ‘Allowed Memory Size Exhausted’ Error in WordPress

Resolving the ‘Allowed Memory Size Exhausted’ Error in WordPress is all about increasing the PHP memory limit in WordPress. There are several ways to go about it. Any one of these three ways should solve the problem:

  1. Editing the wp-config.php file
  2. Editing the php.ini file
  3. Editing the .htaccess file,

However, you need to analyze the additional memory that would be required because it will be different across different installs.

Editing the wp-config.php file

This is the most popular and simple way of increasing the PHP memory limit in WordPress. In this method, we will be editing the wp-config.php file. Ensure that you back up the file on your local computer or desktop before editing it. This helps you in case you need to restore the file to an earlier state.

Now, to resolve the ‘Allowed Memory Size Exhausted’ error, just add the code below in the file before the line that says “That’s all, stop editing! Happy blogging”.

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

Once you’ve made the edit, go to your website URL to see if the error is resolved. In some instances, this method may not work. This might happen if you have shared hosting and the hosting provider does not allow such a change. In that case, you need to contact your hosting provider to resolve this issue.

Editing the php.ini file

The php.ini file is a configuration file that can be used to control resource limits. It is read when a PHP script is executed or else when PHP starts. In the case of a live install, you will find the php.ini file within the root of your install i.e. within the /public_html/ folder. In most cases, the file is set up by your host. For instance, if you’re using Cpanel as your control panel, ensure that the “Show Hidden Files” box is checked and hit Go. Be sure to back up the file before editing it.

Now, open the file and add the following line in the code:

memory_limit 512M

Finally, hit save and close the file.

Editing the .htaccess file

If editing the php.ini file didn’t work for increasing the PHP limit in WordPress, you can try editing the .htaccess file. You will find this file located within the root of your WordPress files. It is advisable to back up this file in case you need the original one.

To increase the memory limit, add the following code to the bottom of the file:

php_value memory_limit 256M

Save the changes and check if the ‘Allowed Memory Size Exhausted’ error is resolved.

These were three easy and quick ways in which you can resolve the ‘Allowed Memory Size Exhausted’ error in WordPress.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top