How To Fix WordPress Fatal Error Allowed Memory Size

How To Fix WordPress Fatal Error Allowed Memory Size

Stuck with this message “WordPress fatal error allowed memory size”?

If you’re seeing this memory size message, “Allowed memory size of 41943040 bytes exhausted”, don’t be scared. Thanks to WordPress, now you can make your own website with hundreds of themes. Sure, it took time for the platform to grow into a content management system and allow us to make such resourceful websites.

Till now, it might sound all good and flexible. However, one needs a bit of tech-savviness while operating WordPress too. Like any computer or technical operation, WordPress comes with its own set of limitations and errors. Most of us have faced an error or two. WordPress’s Fatal error allowed memory size exhausted is a fairly common one at that.

Here is the way to fix it step by step but first we need to know what PHP memory limit and script mean

How To Fix WordPress Fatal Error Allowed Memory Size

What is PHP Memory Limit?

PHP’s memory limit’s on a per-script basis, just like the speed limit of the highway is per vehicle. Say PHP’s memory limit is set up to 1GB. Now, this doesn’t make the scripts stack together on one another to use the 1GB we allocated early on.

Before we go deep into the Memory Limit discussion,

What is a script?

So, we have said that the memory limit is a per-script-based setting. Now, what is a script?

A script is simply a written command or a written computer language that says the program what and how to execute. That is, the script sets the boundaries and is also the executioner. You need not compile a program every time you want to run it. Instead, you ask the script to do so.

Since scripts are written codes, they are also easily editable. Scripts run in 2 ways. One is on the server side, while the other is on the client side. Most websites nowadays use both to optimize performance and also increase dynamism and functionality.

What is the script?

Server side Scripts

PHP, Perl, Ruby, Python, etc., are server-side scripting languages. This means that when you access a website, it runs the script on the hosted server and then displays the result to you.

Client-side scripts

There is also a client-side scripting language like JavaScript. Actually, JavaScript is used on both the server side and the client side. You may ask why is the website eating your resource by running it on your computer. Well, this is also to increase efficiency.

JavaScript is used to show interstitial objects on the screen, and also to play web-based games. Running the script and sending the result back and forth would eat away a lot of time. Typically, scripts are open-sourced, so users can view and edit them! Pro tip: Right-click on any webpage and click on Inspect. You will find the JavaScript yourself along with the HTTP codes.

The greatest thing about scripts is that you can run them on any operating system with a little tweak here and there. Also, scripts are just commands. You will need the actual programs or resources to execute them.

Increase the memory limit in the PHP.ini file

Option 1: Increase the memory limit in the PHP.ini file

You can directly increase the PHP Memory Limit when you have access to edit the PHP.ini file. Most Shared hosting servers don’t usually give you such an entry to the PHP.ini file. However, some servers let you build a copy of PHP.ini in your own site Directories. Then, the data/values will take the place of the default PHP.ini values.

For this, simply create a “php.ini” file in your main directory where the WordPress site is. In your created script, just add the line, “memory_limit = 128M,” increasing the limit to 128MB. Now, do not worry if you fear that the main file will lose all the data. The newly created one can only change values that are in the original one. It can’t affect the command lines.

Option 2: Change the memory Limit using wp-config.php

This is another easy way and risk-free at that. It is understandable if you do not have access to edit the php.ini file or if you do not want to edit such sensitive files. In such cases, you can increase the limit by editing the wp-config.php file. Add the line:


, and now, your limit is 128 MB.

Option 3: Modify the .htaccess file

You usually won’t find the .htaccess file in WordPress, even though it is a must for raw-coded sites. However, if you have activated the .htaccess file for a reason, maybe for a “301 Redirection,” you can use it to increase the memory limit. Just edit the file and add the command line

 “php_value memory_limit 128M”

 in the .htaccess file to increase the limit to 128 MB.

Option 5: Contact  the Hosting Service Provider

There is a good chance that your shared web host has limited the memory usage to a point, and no matter how you change the limit from WordPress or file manager, the sites can’t just access the needed memory. So, you should contact the service provider and ask them if they have done so. Get a deal that might benefit you with the increased memory, or look for a better web host and opt for a private server.


With all the high-level language and frameworks in work all around us, it is reasonably easy to understand where the codes, the commands in, and even the auto-generated scripts are. Even without any formal training, or certification one can quickly figure out the solution to errors if shown the right direction.

Hopefully, with our article, you now know about the WordPress fatal error that allowed memory size exhausted and how to fix it. Before you tweak any documents, it is a safe approach to back up all the data using an FTP tool or a plugin.

Eng.M.Thatwart is a developer and author at wpqanda, who is passionate about WordPress, digital marketing, and website builders. He enjoys sharing his knowledge through his writings.