How to Increase WordPress Memory Limit

Facing the WordPress PHP memory limit error? It might mark itself as a ‘fatal error’, but we’ve got a simple solution: increase WordPress memory limit. Here’s how to do it.

In this article, we’ll discuss everything you need to know about the WordPress PHP memory limit and how to increase it. Let’s start. 

What is the WordPress PHP memory limit?

WordPress is a piece of software that runs on the PHP programming language. PHP processes its queries, calculations, and does a lot to generate the output of your website. 

As we all know, the software requires some RAM space (memory) to operate. The same thing applies to the PHP scripts in your WordPress setup.

By default, WordPress may have a PHP memory limit of 32MB to 64MB. But with all these plugins and functionalities, 64MB may not be enough. When WordPress detects that the site has reached the maximum allocated memory limit, it fires a fatal error like the following:

“Fatal error: Allowed memory size of xxxxxx bytes exhausted”

Why you need to increase the memory for WordPress

Simple. You need to increase the WordPress memory limit to avoid these fatal errors that originated due to lack of memory. A good PHP memory limit for WordPress is 256MB. According to experts, 90% of the sites are fine with this amount of RAM allocated for WordPress (not for the server or site as a whole).

Is there any upper limit for PHP memory in WordPress?

There’s a recommended amount of PHP memory for most of the WordPress sites. It’s 256MB. If you’re an expert and you run resource-heavy PHP scripts or plugins on your server, you may increase it as you need. 

Get Latest Post Notifications!

Subscribe to our newsletter

But experts don’t suggest setting an unusually excessive amount for the PHP memory limit. And the amount of PHP memory should be limited to make your site safer!

Most of the legitimate WordPress plugins and PHP scripts will need a very small amount of PHP memory limit. 256MB is more than enough in most cases. 

If you set a higher limit, that means the PHP scripts will be able to use that amount of RAM when they want. If you get any malicious script, that may exploit this amount of RAM to exhaust your server resources, kill your bandwidth, and incur a higher amount of server bill. This is why the PHP memory limit is recommended to be set thoughtfully.

Ways to increase WordPress memory limit

If you’re asking how to change PHP memory limit WordPress (or increase it), there are multiple methods for that. We’ll start it with the easiest way. 

Define memory limit in the wp-config.php file

The easiest way to increase PHP memory limit in WordPress is by editing the wp-config.php file. This file contains all the core configurations of your WordPress instance. 

A default limit is set there for many PHP operations including the uploading file size. It’s located in the WordPress root directory.

To find wp-config.php, open the root directory named as public_html or www or html. If your site has a web panel like cPanel or CyberPanel, you can easily open the site’s root directory from the built-in file manager of the panel.

Or, if you use a VPS with no web panel, you can still use an FTP client like FileZilla to log in to your server. Find the webroot in the server and locate the wp-config.php file.

Once you find the wp-config.php file, before starting to edit it, take a full website backup. Also, you can download a copy of the file and keep a backup before editing. This will help regain access to your site if anything goes wrong while editing wp-config.php.

Now, to increase the WordPress PHP memory limit, open wp-config.php in editing mode. Look for this in the file: define( 'WP_MEMORY_LIMIT'

If you find it, the full line will look like this: define( 'WP_MEMORY_LIMIT', 'XXM' );

The XX part will be a number. If it’s less than 256, then make it 256. Or, even you don’t find this line at all, simply add define( 'WP_MEMORY_LIMIT', '256M' ); just before the line ‘That’s all, stop editing! Happy blogging.

Here’s a screenshot of what it will look like after editing. 

Increase WordPress Memory Limit - wp-config php memory limit

Then, save changes. You can check Tools > Site Health > Info > Server > PHP Memory Limit to see whether the change has been applied to your site.

It’s really easy to increase the memory limit in the wp-config file. The wp-config memory limit is your starting point in WP memory limit change. Now you know how to define the memory limit in the wp-config php file.

Learn More: How to Use WordPress Recovery Mode – Complete Guide

Increase the WordPress memory limit via php.ini

php.ini is the PHP configuration file for your server. If you have access to this file, you can edit this to allow your WordPress site to use a greater amount of memory. If editing wp-config.php doesn’t work for you, then you can edit php.ini to set/increase the PHP memory limit.

Finding the php.ini file depends on your hosting. If you use a shared hosting plan, you may not have access to this file at all. It is located in the PHP folder of your server. However, if you can get access to the php.ini file, find this line in it: memory_limit = 

You’ll see a number after the = sign. If it is less than 256, edit the number to make it 256.

You’ve just set 256 for the memory limit. The line will look like this after the edit: memory_limit = 256M ; Maximum amount of memory a script may consume (256MB)

So if you’ve been exploring “increase memory limit wordpress php ini”, this was the solution.

Increase the memory limit of WordPress in .htaccess

If you don’t have access to the php.ini file, you can also edit the .htaccess file (if available) on your site’s root directory. Open the .htaccess file and set the “php_value memory_limit” value to 256M. 

Increase the PHP memory limit via your web panel

If you use a web panel like cPanel or CyberPanel for your site, then you can easily change the PHP memory limit. On cPanel, go to the Software section. Open the MultiPHP INI Editor menu. You’ll find the PMP memory limit adjustment option.

On CyberPanel, go to PHP > Edit PHP Configs > Advanced. The php.ini file will be opened in editing mode. Set your desired memory limit there.

Using a WordPress plugin to increase the memory limit

Last but not least! You can actually increase the WordPress memory limit using a plugin. 

You can avoid manually editing the wp-config.php file. Just install and activate the WordPress WP Memory Limit plugin. You will be able to choose a PHP memory limit from WordPress Dashboard > Tools > WP Memory. 

wp memory plugin

We hope you’ll find these tips helpful. If you still face the fatal error related to exhausting the PHP memory limit, please contact your hosting provider. Probably it’s time to upgrade your hosting plan. 

Also, conduct an audit if there’s any suspicious script wasting your server resources. If the error message persists, contact your web hosting support.

Wrapping up

In this post, we’ve seen multiple ways to increase the WordPress memory limit for PHP scripts. You can start with the panel method if you use a panel like cPanel or CyberPanel. If not, it’s better to try the wp-config.php method. 

If it still cannot solve your problem, try the other methods like editing the php.ini file or .htaccess file. If you’re not comfortable with editing code, you can try the plugin way as well. Please share your thoughts and experience with us via comments!

Disclaimer: This post may contain affiliate links and we may receive a small commission if you purchase something by following them. However, we recommend services/products that we believe good to serve your purpose.

Staff Author
Staff Author

A team of WordPress enthusiasts led by Arafat Bin Sultan, a seasoned professional with over a decade of experience in tech blogging, content marketing, and video creation.

Articles: 234

Leave a Reply

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