Your Dedicated Partner for All Things WordPress

How to Fix Memory Exhausted Error in WordPress?

Table of Contents

One of the common errors that you will see in WordPress is the memory exhausted error.

It will simply show you that the allocated memory has been exhausted. If you are new to the hosting and all this stuff, you will surely think that they are talking about the storage or RAM, right?

However, it is not so. If someone tells you to upgrade the hosting then don’t directly assume they are right. You can fix the memory exhaust error with a simple method.

We will see that method. You can try out that method. If it still doesn’t work then you can think of upgrading your hosting provider.

However, in most cases, this will work like a charm and you will see the website is working again the same as before. Now, we will first see the overview of the error where we will see how the error is displayed, and then we will see how you can know whether it’s the same error. Later on, we will get into the steps to fix it.

Make sure you go through the complete article carefully as there are many things that we will discuss here. All of them are important when it comes to fixing Memory Exhaust error.

Overview of Memory Exhaust Error

This is the part where we will learn why this error is shown and how it is displayed. Later on, we will get into the methods to fix the Memory exhaust error in WordPress.

WordPress has fixed memory allocation that is decided by the script itself. In other words, WordPress can only use X amount of memory from the server. By default, certain memory is set here.

However, as we start building the website, there are some of the plugins which require more memory. Of course, if you are running an eCommerce website or a website with more than 15 plugins, you will face such issues.

This is why we will have to increase the allocated memory. Don’t worry, we can do it by just adding one single line to the code.

There are various ways this error is displayed. Here is the most common text that people see.

Fatal error: The allowed memory size of XXXX bytes exhausted (tried to allocate YYYY bytes) in /public_html/wp-includes/plugin.php online ZZZ

Of course, the path here can be different. Also, instead of the X, Y, and Z, you will see certain numbers. This represents the bytes and the line.

Generally, you will think that there is something wrong with the plugin or the file, right? However, it is not so.

By default, WordPress allocated 64 MB only. This is not enough to perform several tasks. Therefore,e you will need more memory.

Also, increasing memory will solve other possible errors. For example, due to low memory, you might not be able to upload large images in the library. similarly, many errors will be solved automatically by just increasing the allocated memory.

Let’ see the actual method to increase memory.

How to Fix Memory Exhaust Error in WordPress

Whether you are seeing the error on the website’s homepage or you are seeing it while uploading an image, the solution is the same.

Let’s see the solution to the error and see how to fix the memory exhaust error in WordPress.

Backup your Website

Before we see the solution, it is highly recommended that you take a backup of your website. You can use any plugin to do it or you can do it manually. If you are seeing an error on certain pages only, you can use a plugin.

The plugin will just compress the files of your WordPress directory and paste it into another folder. In the same way, go to PHPMyAdmin and open the database of your website. Just click on the operations and export of the database.

In this way, you can backup the entire website with just a few clicks.

If you don’t want to back up the entire website, you can just backup the wp-config.php file which we will change. It is not needed but if you are new, you can do this for safety.

Open the wp-config file

Your first job will be to open the wp-config.php file. Your first job is to open the wp-config.php file.

You can do it in two ways. First, open the file manager and head over to the WordPress directory inside your website.

It will be with the name of your website. In simpler words, you will see the folder with the same name as your website. Alternatively, if you are using single domain hosting, you can open the public_html file and everything will be there.

Inside the main directory, you will find a file named wp-config.php. There is only one file with a similar name. So, it will be extremely easy to find.

Once you find the file you are looking for, you need to open it.

Now, there are two ways to edit the code.

You can either download the file, change the code in the editor on your computer, and then upload it back.

Alternatively, you can do it online. You just need to right-click on the file and then select “code edit” from there to open it.

Either way, the method is the same. We highly recommend you to download the file before you make any changes. If you are changing it on your computer, you need to save one copy somewhere without editing anything.

So, in case, something goes wrong, you can directly use that backup for your safety. In this way, your files and your website will be safe. You don’t need to save it again if you have already taken the backup of your website.

However, if you haven’t then you can have this file.

Once you do all these things, it is time to make the changes in the file.

Add the Following Code

Now, you will have to add one line to the file. Open the wp-config file and then you will have to add the following line in the code.

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

Please note that don’t enter any number in the file.

You can only allocate a certain memory in the file.

The default memory is 64 MB and we have increased it to 256 MB. If your host doesn’t allow to allocate this much memory, you can also try 128. Just change 256 to 128 and that’s it.

Now, you just need to save the changes in the WordPress website.

Once you save the changes, you can try opening the website again to see if the error is gone or not. In most cases, the error will be gone.

If not, you can surely increase the memory with the PHP version. We will also see that.

Increase Memory with PHP Version

To do it from the PHP version, you will have to open your cPanel and inside it, you will have to select the “Select PHP version” option.

Click on it. Now, you will have two options. You can either change the PHP version to the latest one. Alternatively, there is one other way to do it.

To change it manually, there is an option called “Change PHP options”. Just click on it.

Now, you will see a list of options that you can choose from. From the given options, you will have to find the “Memory limit”.

Inside the memory limit option, you will have to select from the drop-down options. You can select 256 MB from the list.

That’s pretty much it. Now, you can click on the save changes button and open the website again.

You will see that the website will now open. If you are still seeing the error, check out this last method that you can use.

Contact/Upgrade the Hosting

We will first contact the hosting provider to see if the memory can be increased or not.

Just contact the hosting provider with the live chat option. They will increase the memory from their side or will tell you what you need to do.

Alternatively, if the other resource of the website is exhausted, you can also try upgrading your hosting. Most of the shared hostings have limits. If you exhaust the limit, your website will show an error or will slow down. Therefore, you need to make sure that the resources are not exhausted.

To do this, we will have to open the cPanel and you will see the resource usage on the right side. If you see the red line everywhere, it means that the resources are full.

Final Words

To conclude, these are some of the methods to fix memory exhausted error in WordPress. You can also check the logs. Sometimes, it is also due to the particular plugin. In most cases, the hosting provider will give you the information. So, they will tell you which plugin is causing the issues. You can then remove that plugin or change the configuration in that plugin. You can also check the server logs to know more.

How to get started?

Learn more

WordPress Maintenance

Save 33% with our Annual pricing plan.

Get Started

Coupon Code Applied!

Take your time and continue browsing our services.

Alexey Seryapin
Founder of WPServices