How to Increase WordPress PHP Memory Limit (4 Methods)

Are you facing a WordPress error that says “Allowed Memory Size Exhausted”?

This is one of the most common WordPress errors, and increasing the WordPress PHP memory limit is a simple solution.

If you have a multimedia-heavy website, the default WP setup will not be enough, and you will need to upgrade at some stage.

In this post, We’ll show you how to increase the WordPress PHP memory limit to fix the WP memory limit or WP memory exhausted error.

What Is WordPress Memory Limit Exhausted Error?

WordPress is written in PHP, a server-side programming language. Every website requires a WordPress hosting server to work properly.

Web servers work in the same way as any other computer. They require memory to run several applications efficiently at the same time. Server administrators allocate specified memory sizes to various applications, including PHP.

When your WordPress code needs more memory than the default allocated memory, you see this error.

Memory exhausted error displayed on a WordPress site

By default, WordPress automatically tries to increase the PHP memory limit if it is less than 64MB. However, 64MB is often not high enough.

Having said that, let’s see how to easily solve the allowed memory size error in WordPress.

4 Methods To Increase WordPress PHP Memory Limit

Below, we’ll show you four different methods you can try to increase the WordPress memory limit.

Unfortunately, we cannot guarantee that all of these methods will work for you because it depends on your hosting environment’s configuration. That’s why we’ve provided several options; at least one of them should work for you.

Because some of these fixes require changing core WordPress files, we strongly advise that you back up your website first.

There are so many backup plugins available, but the UpdraftPlus plugin allows you to upload your work to different cloud storage sites.

Once you’ve got a recent backup of your site, here are four different ways to increase the WP memory limit.

1. Edit Your wp-config.php File And Increase wp_memory_limit

To start, first, you need to edit the wp-config.php file on your WordPress site. It’s in the root folder of your WordPress site, and you’ll need to use an FTP client or your web hosting control panel’s file manager to access it.

Now, open the wp-config.php file and search for the following phrase – WP_MEMORY_LIMIT.

It looks something like this:

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

If this code is already present in your wp-config.php file, you need to increase the limit number. For example, you can increase the memory limit from 32M to 256M.

If this line of code is missing from the file, you’ll need to add it. Simply add this just before the line that says ‘That’s all, stop editing! Happy blogging.’

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

Once finished, save your changes and re-upload your wp-config.php file to your server.

Now visit your WordPress site, and the memory exhausted error should disappear now.

2. Edit Your PHP.ini File

If editing your config file doesn’t work, you can try editing your PHP.ini file. If you’re using a shared hosting service, you won’t be able to change this file because it governs server settings.

Look for the line memory_limit = 32M and update it to 256M.

It is also best to change the max_execution_time line. This line determines the time in seconds that a PHP script is allowed to run. If the time limit is exceeded, PHP throws an error. Increasing this number provides your scripts additional time to run, which is useful if you want to use more memory-intensive services and plugins.

3. Edit Your .htaccess File.

If you don’t have permission to modify PHP.ini, your last option is to edit your .htaccess file. .htaccess file begins with a dot because it is a hidden file. If you don’t see it in your root folder, ensure your SFTP file manager isn’t hiding the files from view.

To increase PHP memory, add the following lines to your .htaccess file:

php_value memory_limit 256M

If the PHP value memory limit has already been set, then increase it.

4. Use a Memory Increase Plugin.

Another way to increase the WordPress PHP memory limit is to use a plugin, such as the Memory Usage, Memory Limit, PHP and Server Memory Health Check and Fix Plugin.

This plugin works with WordPress versions 5.2 and higher and allows you to change available PHP Memory without accessing or modifying files.

Summary

You may upload files and install new software to your site most of the time without any problems. However, you may face the WordPress PHP memory limit error at some point.

Let’s briefly go over four methods to increase the WordPress memory limit and resolve this problem:

  1. Increase the PHP WordPress memory limit by editing your wp-config.php file.
  2. Change your server settings by editing PHP.ini.
  3. Edit your .htaccess file to increase the PHP memory limit.
  4. Use a memory increase plugin.

That’s all; we hope this post helps you solve the WordPress memory exhaustion error by increasing the PHP memory limit. If you like this post, then read more posts like this on our website.