Increase the PHP Memory Limit in WordPress

Once you start installing WordPress plugins, they require WordPress to do more behind the scenes and thus arises the need to increase the PHP memory limit in WordPress.

For example, we run our websites with the extremely light-weight Beaver Builder page builder plugin for WordPress.

As an addon, we also install the Ultimate Addons for Beaver Builder plugin because it extends the Beaver Builder core plugin and provides a whole range of new custom features that help us build our client websites faster in our web agency.

Because this addon does more it needs more resources, so we need to increase our PHP memory limit.

What is PHP memory and what is it used for?

PHP memory refers to how much PHP information can be stored at any given time to perform certain tasks.

One of the reasons your PHP memory is limited is to ensure your website doesn’t hog the resources on the server and slow down other websites (when you’re on shared hosting).

When to increase the PHP memory limit in WordPress

When you see an error like Fatal Error: Allowed memory size of xxx bytes exhausted on your website, that’s when you know you need to increase your PHP memory limit in WordPress.

You will usually see a white screen on the front end of your website with this text when the page tries to load.

Also, sometimes your page will only half load and then stop rendering. For example, you may click on a page on your website and it loads everything but your footer.

If you inspect the source code of that page, you will usually see that the HTML has stopped rendering.

If you inspect your HTML and it has prematurely stopped rendering, this is a sign that you need to increase your PHP memory limit.

You can exhaust your PHP memory limit by doing many things

When you ask WordPress to do too many things at once, that is when you can exhaust your PHP memory limit.

Each time you install a new WordPress plugin, you’re asking WordPress to do more things with your website, which means more tasks at once. And if the PHP memory cannot do all those tasks at once, it throws this error.

Thus, a common cause of a PHP memory limit error in WordPress is when you install new plugins.

[clickToTweet tweet=”Spoiling yourself with fancy plugins is (usually) unnecessarily spoiling your website.” quote=”Spoiling yourself with fancy plugins is (usually) unnecessarily spoiling your website.”]

How to check your current PHP memory limit

Taken from the WordPress codex, WordPress will come with 40MB of PHP memory, as per below.

By default, WordPress will attempt to increase memory allocated to PHP to 40MB (code is at the beginning of /wp-includes/default-constants.php) for single site and 64MB for multisite.
– Click here to visit the WordPress codex

Output your current PHP info

Using FTP or cPanel, create a new file named myphpinfo.php in the root of your server. So, if you WordPress website is installed in your public_html folder, create the file here.

Increase the PHP memory limit in WordPress by creating a new file for checking

Next, add the below code to the file and save the file.

<?php phpinfo(); ?>

Just like the below.


Now, navigate to this file in your browser by entering it into the URL bar.


Then search for memory_limit and to the right you’ll see the current value of your PHP memory limit.

WordPress has a default 40M limit for PHP Memory.

40M is quite small and chances are that if you’re reading this page you’re most likely already out of PHP memory.

Let’s increase our PHP Memory limit for WordPress.

How much PHP memory you need

We usually recommend bumping it up to 128M of PHP memory but you may need more depending on the plugins you’re using. If you’re using WooCommerce we’d recommend going up to 256M.

Ways to increase the PHP memory limit in WordPress

NOTE! in the below examples, we’ll be increasing our memory to 128M. If you’re using lots of plugins or 128 still causes a memory issue, try increasing the value to 256M.

Step 1 (required): Edit your wp-config.php file

IMPORTANT! The PHP memory limit in WordPress can be separate to the PHP memory limit on your server, so you should always complete this step.

Using your FTP client or cPanel, navigate to the root folder of your WordPress install and edit your wp-config.php file.


Above the line that says /* That’s all, stop editing! Happy blogging. */ add the following PHP.

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

So now your wp-config.php file should look something like the below.


Save the file.

Option 1: edit your PHP.ini file

Using your FTP client or cPanel, navigate to the root folder of your WordPress install and edit your PHP.ini file.

If there is not a PHP.ini file the root of your WordPress install, create it.


In this PHP.ini file in the root of your WordPress install, add the following code.

memory_limit = 128M;

And save this file.

Option 2: edit your .htaccess file

Using your FTP client or cPanel, navigate to the root folder of your WordPress install and edit your .htaccess file if it exists.

The .htaccess file will exist if you have custom permalinks (i.e. anything other than the default settings) set under WordPress Dashboard > Settings > Permalinks.

TIP! If you’re using cPanel you may need to show hidden files (dotfiles). You can do this when using cPanel > File Manager by clicking Settings in the top right and then CHECKING show hidden files (dotfiles). These two steps are shown below.


If it does not exist, create the new file named .htaccess in your WordPress install root folder.

In the .htaccess file add the following line of code.

php_value memory_limit 128M

Then save the file.

How to know if one of these methods above has successfully increased your PHP Memory Limit for your WordPress website

After you complete one of the methods above you should go back to the myphpinfo.php file you created in your WordPress install (at the start of this article) and check to see whether the memory_limit value has changed to the value you’re trying to increase it it. If this value does not change in the myphpinfo.php file then the change has not worked in your hosting environment and you should try the next method.

For example, in my hosting environment the PHP.ini method did NOT work. I confirmed this because I went to the myphpinfo.php file I created and the memory_limit value was still 40M.

After I completed the .htaccess method above, I recheked the myphpinfo.php file and the value has correctly increased, as shown below.

After each step in this tutorial, check your myphpinfo.php file to see whether the most recent code you’ve added has successfully been implemented to increase the PHP memory limit in WordPress

Now, you may be wondering why it says 128M and then 40M to the right.

After doing some reading on this I have found the following to be true:

  1. The left value is called the Local Value
  2. The right value is called the Global Value
  3. The Local Value overrides the Global Value

So, in the above, the 128M will override the 40M and that’s exactly what we want. More PHP Memory!

Importantly, delete the myphpinfo.php file after you have successfully completed this tutorial

Once you’ve successfully managed to increase your PHP memory limit in WordPress, or if not of these have worked and you need to contact your web host, delete the myphpinfo.php file from your server.

Wrapping it up

Depending on your web host and their hosting settings, different methods will work for different people.

Try all of the above and if you’re still in no luck reach out to your web hosts and plead with them to increase the memory limit for you.

Most hosts will do this for you if it is within a safe range.

Do you have any other methods that work for you?

Please leave a comment below and help other Beyonders who visit this page in search of fixing this error.

Hey! I'm Grant Ambrose,

My WordPress website generates millions of dollars in sales each year and I put together this website to help you do the same

I believe that a lot of the time, we aren't doing things that will help our business NOT because we don't know how to do it, but rather we don't even know it is possible. My website aims to change this. My website is here to help show YOU what is possible - what YOU could set up in your business with WordPress to increase sales, automate tasks and (ultimately) turn your ideas into working WordPress solutions.

2 thoughts on “Increase the PHP Memory Limit in WordPress”

  1. Great article. It inspired me to see if I could find any free plugins that might make the procedure easier, and I found WP Config File Editor – it shows your current PHP memory limit in a simple form and you just change the number, click update and you’re done. I started at 40MB, changed it to 256MB and used another free plugin – RS System diagnosis (which showed that I was using 46MB) – to confirm that it is now 256MB and it is 🙂

    1. Great Tony. Good to see you found something that worked for you. I recommend limiting plugins where you can and the tutorial here discusses an easy way to do this without additional plugins so this method is always advised.

      Thank you for your comment!

Leave a Comment

Your email address will not be published. Required fields are marked *

Grow your WordPress business by getting...
My best tips to your inbox!

I'll send you emails when I publish content I think will help you and your business. You can opt-out at any time and change the topics of emails you get.

This site is not a part of the Facebook website or Facebook Inc. Additionally, this site NOT endorsed by Facebook in any way. FACEBOOK is a trademark of FACEBOOK, Inc.

Scroll to Top