How to Increase WordPress PHP Memory Limit

So if you’re getting a memory limit error on your WordPress dashboard, I will show you how to fix that right now. This method includes going into your cPanel. I’ll be doing it with HostGator because that’s my hosting provider. But if you have something else, I’m sure it’ll probably work the same way. 

The problem I’m having is that the current memory limit is set to 40 megabytes, and I want to increase that because, on this particular website, I’m going to be using a couple of plug-ins that require a lot more memory. 

How to fix memory limit error on WordPress

This involves going into your website’s back end and editing some custom code. If you don’t feel comfortable with that, maybe this isn’t for you, but it’s simple. It’s just copy-paste, and I’ll provide the code in the description. So you shouldn’t have a problem. Just paste it in the same place that I put it. 

  1. Access your cPanel

    First, go to your HostGator account. You could log in straight to the cPanel, but I always log into the hosting portal. 

  2. Find the website you need to fix

    From this point, you’re going to want to click File Manager. Here’s a list of our websites. We’re going to look for the particular website we’re trying to increase memory on. 

  3. Located wp-config

    Locate the WP config file, right-click it, and click Edit. (If you double-click WP config instead of right-clicking and go into edit, it’s not going to open the file, it’s just going to download it to your downloads folder.) Next, you will see some PHP code. It can look intimidating but don’t worry, don’t mess with anything else here. Just do what we’re going to do, and you should be fine. 

  4. Paste this code

    Now, go down to the right where it says “MySQL Settings,” and paste this code:

    define( ‘WP_MEMORY_LIMIT’, ‘128m’ );

    That’s all we have to do.  Now click Save, and the alert should go away. Now you can use those plug-ins that use a little bit more memory. 

Reasons why your code might not be working

There are a few reasons why your code might not be working.

1. You have a syntax error

If you see a red x on the code page, it means the code syntax is not written correctly and will not work; it might end up crashing your entire website. So if you see an X there, that means you typed something wrong. Check that you didn’t put a comma where it shouldn’t be. 

2. You are missing a comma

Another reason for this code not working is that you are missing a comma. You might have found the code from somewhere else on the internet,  maybe Stack Overflow or some other website, but when you grabbed it and tasted it exactly, the original poster was missing the comma.

3. You are missing a semicolon

Another reason you might experience trouble is if you are missing a semicolon at the end of the code. That’s a big one because it’ll make something else not work correctly and break your code altogether. So remember to add the semicolon.

Are you a visual learner? Check out my video below titled “How to Increase Maximum PHP Memory Limit and Remove Limit Error on WordPress from cPanel” from my YouTube channel, as I show you all this firsthand.

A video titled How to Increase Maximum PHP Memory Limit and Remove Limit Error on WordPress from cPanel‘ from the Yerain Abreu YouTube channel.

Frequently asked questions (FAQ)

Do you still have questions? Below are some of the most commonly asked questions about fixing WordPress issues.

What is PHP used for?

PHP is an open-source server-side programming language that many web developers utilize. It is also a general-purpose programming language that can create various applications, including Graphical User Interfaces (GUIs).

How do I check the PHP memory limit in WordPress?

You can quickly check your PHP memory limit by clicking on Tools > Site Health > Info in your WordPress dashboard. Then, search the Server tab for the PHP memory limit item.

Does PHP 8 use more memory?

WordPress memory use was roughly 2-8 MB with PHP 7.4 and before. WP memory use increased to more than 28-30 MB after upgrading to PHP 8.1. Because the (default) WP memory limit is 40 MB, 30 MB is now very near the limit.


Okay, so that concludes this video. What do you think? Let me know in the comments below (I read and reply to every comment). If you found this article helpful, check out my full blog and subscribe to my YouTube channel. Thanks for reading!

Leave a Comment