This tutorial offers simple solutions to increasing your WordPress PHP memory.
While using WordPress, there are a few common problems or errors that you might have to contend with. Among the most common is the WordPress memory limit error, also known as a "PHP memory limit error".
The PHP memory limit error is generally one of the easier WordPress errors to fix because you know exactly what the problem is: certain scripts on your site don’t have access to enough memory. The solution is simply to increase your memory limit, and there are several ways to do this.
Below, we'll discuss two easy methods.
The first place to try is the wp_config.php file of your website. This file contains the basic configuration details for your website, including its PHP memory allocation. Increasing your PHP memory limit from here is usually enough to resolve the problem.
You’ll find this file in the root folder of your WordPress site. You can access this through File Transfer Protocol (FTP) or by using cPanel.
You will need to provide the relevant details as prompted on the screen. These will be:
Login — your desired username
Password — any password of your choosing
Directory — the directory you would like to access. In this case, this will be your root directory, so enter 'public_html/'.
NB: In most cases, your hosting provider will provide you with FTP details by default so be sure to check with them before you create a new FTP account.
If you’ve never done this before, the first thing you need to do is install an FTP client. To set one up, you’ll need your website’s FTP credentials. Typically, you can find these credentials in your hosting account. If you face any difficulties, however, simply reach out to your hosting provider and they’ll show you where to find them.
Alternatively, you can create your FTP account yourself. Login to cPanel then navigate to Files Manager > Files > FTP Accounts.
Once you have your FTP client set up, you can access your site’s files. To start with, you'll need to find your site’s root folder. For WordPress websites, this will usually be a folder called public_html. It may also be a folder with the name of the website. Once in, you will see a file named wp-config.php.
You’re going to have to make some changes to this file, but you'll need to exercise a bit of caution as any errors may potentially break your website. Before you go any further, back up your website as a safeguard.
After backing your site up, open the wp-config.php file and look for this line:
define( 'WP_MEMORY_LIMIT', '40M' );
The value, 40M, might be different for you depending on your hosting service. It’s also possible for this line not to appear at all.
If you do find it, simply change the value. 256M is usually enough memory to support pretty much any type of website.
If you can’t find this line, look for the line that says: “That’s all, stop editing! Happy blogging.” Then paste the same code right above it:
Save your changes, and your website should be back working as normal.
If you keep getting the same error message after a few tries, however, then it’s likely that you’ve exceeded the maximum limit allocated by your hosting service. In this case, you'll need to contact your hosting service to ask for a limit.
Just like with an FTP client, you can access the wp-config.php file through cPanel. Start by logging in. Scroll down to Files > File Manager > Public_html > wp-config.php. Once you find it, right-click and select Edit.
This will open up the wp-config file in cPanel's native editor. Follow the same steps outlined above for editing the wp-config.php file to increase your PHP memory limit.
While editing the wp-config file is usually the preferred method for increasing the PHP memory limit, there are some alternative methods that you should know about.
As we've demonstrated, you can increase your site's PHP memory in the wp-config file in cPanel. There are other options within cPanel that allow you to adjust PHP memory too. One of them is the PHP selector tool.
Once in cPanel, scroll down to Software > Select PHP Version > Options.
In the resulting interface, scroll down to memory_limit and select an appropriate figure.
Note: This option may not be available for all hosting services.
The amount of space and memory you get access to depends on your hosting provider and the hosting plan you pay for. Most new website owners go for cheaper shared hosting plans that may allocate little PHP memory.
While this is usually not a problem at first, you’ll inevitably reach the limit as your website grows and you start adding more plugins.
If you followed the steps above to increase your website’s PHP memory limit and ended up unsuccessful, chances are, you’ve exceeded the memory allowance of your hosting plan.
Depending on your circumstances, you might have to choose a different hosting plan, switch to a new hosting provider, or upgrade to a higher tier. Whatever the case may be, be sure to pick a reliable host that you can count on to give you access to high-quality resources.
The PHP memory limit error is one of the more commonly occurring errors on WordPress. If you use cheap hosting plans, have multiple plugins performing complex functions, or if your website is growing at a fast rate, you're likely to encounter this error sooner rather than later.
Increasing your site’s memory limit through the wp-config file is an easy and free solution, but the easiest way to prevent a PHP memory error from occurring in the first place is to use a reliable hosting provider and a solid hosting plan. Not only will this give you better memory allocation options, it'll also give you access to other high-quality resources that can improve the overall performance of your site.
Launching your own WordPress site? Here are the best WordPress hosting providers to minimize headaches and maximize performance.
David is a WordPress lover who is passionate about helping small businesses grow!
Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!