fbpx
Blog

How to Increase the PHP Memory Limit in WordPress

How to Increase PHP Memory Limit in WordPress, featured image

Much like any other piece of software, WordPress requires memory to run smoothly. If the content management system (CMS) doesn’t have enough memory allocated for it, you’ll run into the occasional PHP memory limit error. In many cases, this error can prevent you from updating your site.

The good news is that there are multiple ways to increase the memory allocation for WordPress. If your web host allows for it, increasing your PHP memory limit can be as easy as adding one line of code to a specific file.

In this tutorial, we’ll go over two ways you can increase the PHP memory limit in WordPress. Let’s get to it!

What Is the PHP Memory Limit in WordPress

As you may know, WordPress was created using the PHP programming language. This means the CMS also requires PHP to run (as well as other components, such as a web server and database software).

If you’re using a server that doesn’t allocate enough PHP memory, WordPress won’t be able to run some critical scripts for your site to work. You might still be able to carry out most tasks, but at some point, you’ll likely run into a PHP memory limit error.

The simple solution to this problem is to increase the amount of memory that WordPress has access to. By default, the CMS will try to set at least 64 MB of memory for PHP upon install. However, some web hosts may allocate more or fewer resources to your site.

You can check your current PHP memory limit by accessing your dashboard and going to the Tools > Site Health page. From there, go to the Info tab and select the Server option.

Checking your website's PHP memory limit.

Given that allocating more resources here isn’t a hardship, if your PHP memory limit is under 256 MB, I recommend increasing it. This is despite whether you’ve run into any errors yet.

How to Increase the PHP Memory Limit in WordPress (2 Ways)

There are two ways to increase the PHP memory limit in WordPress.

The first involves adding a single line of code to one file. Let’s check it out.

1. Modify Your wp-config.php File

For the uninitiated, wp-config.php is one of WordPress’ core files. In other words, this file contains critical information such as your database credentials and PHP memory limit.

To edit the wp-config.php file, you’ll need to connect to your website via File Transfer Protocol (FTP) using a client, such as FileZilla.

If you’re not sure what your FTP credentials are, I recommend you check the registration confirmation email you received from your web hosting provider when signing up. In some cases, you can also set up new FTP accounts from your hosting control panel.

Once you locate your FTP credentials and connect to your website, navigate to the WordPress root folder. 

That folder is usually called public_html, but it can also appear under other aliases, such as www or your site’s name. Once you find it, open the directory and you should see a list of files and folders.

Locating the wp-config.php file

The wp-config.php file should be within this directory.

Once you’ve found it, right-click on the file and select the View/Edit option. This will open the file using your default text editor.

Opening the wp-config.php file.

Note that the screenshot above doesn’t show the entire file, given that it usually contains sensitive information, and most of it is irrelevant for your needs right now.

The part you want to keep an eye out for is the line reading, “That’s all, stop editing! Happy publishing”. This is the end of the file, and before it, you’ll want to add the following code (in the example above, it’s line 68 but it could be different for you):

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

Naturally, you can change the limit to another figure, but this is usually more than enough for most sites. After you add the line to your wp-config.php file, save your changes and close it.

Next, try accessing your WordPress website again and heading to the Tools > Site Health > Info tab to look at your server settings. If your PHP memory limit is still showing the same number as before, it might be due to your web hosting provider.

In some cases, your web host won’t enable you to make direct changes to your PHP memory limit, which brings us to option number two.

2. Contact Your Hosting Provider or Upgrade Your Plan

The easiest way to check if your hosting provider prevents you from increasing your PHP memory limit is to contact them. In our experience, some web hosts will increase the PHP memory limit for you if you ask them.

However, in a few cases, this might not be possible depending on your hosting provider and the plan you’re on. For example, with shared hosting plans, you’re usually very limited when it comes to resources.

If your hosting provider tells you that you can’t increase your PHP memory limit, you might have to upgrade to a better plan. Any type of plan above shared hosting should give you more than enough resources so that you won’t run into the PHP memory limit error again.

In any case, most reputable WordPress web hosts won’t give you any trouble when it comes to increasing your PHP memory limit. In fact, some of our top WordPress hosting picks outright give you more resources than you might need. If you do find that you’re having memory limit problems and your current host is unwilling to help, it could be time to look elsewhere.

Conclusion

The PHP memory limit error is one of the most common problems among WordPress users. Even though it won’t break your site in most cases, it can be annoying. Fortunately, it’s remarkably easy to sidestep this error by making a simple change to your server’s configuration.

If you want to increase your WordPress PHP memory limit, there are two ways to do it:

  1. Modify your wp-config.php file.
  2. Contact your hosting provider or upgrade your plan.

Do you have any questions about how to increase the PHP memory limit in WordPress? Ask away in the comments section below!

FREE COURSE

Learn How To Put Your
WordPress Site
Into Hyperdrive

Speed up your site by 30-40%
by using simple techniques

Join Free Course
Share This Article:
Facebook Twitter

Related Posts

Leave a Reply

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