How to Increase Wordpress Memory Limit

Dylan Winn-Brown

Written by Web Developer & Business Owner

July 28, 2022
How to Increase Wordpress Memory Limit

WordPress is a very powerful content management system that allows users to create and manage a wide range of websites from simple blogs to complex ecommerce stores. However due to these capabilities, more in-depth technical knowledge is sometimes required to fix issues that may come up during the day to day management of your WordPress website.

One of the most common errors users come across is a message that states “Allowed memory size exhausted.” Thankfully, increasing the WordPress memory limit is quite a straightforward process and can be achieved in a number of ways.

In this article, we’ll cover the three most common ways to increase your WordPress Memory Limit and resolve this error once and for all. But first, it’s important to understand what causes this error and what can be done in the future to reduce the chances of it happening again.

Why Am I Getting This Error?


Upon the initial setup of your WordPress website you will have purchased a WordPress hosting plan to get your site online. If you’re not sure where you purchased this from, it is often the same place as where you bought your domain name from but may have also been recommended to you by your web developer.

Depending on where you purchased your hosting from and which plan you chose, your website will have been allocated a certain amount of resources by the web hosting provider. These resources are what powers your website and sometimes when carrying out resource-intensive actions (like uploading lots of files to the media library or installing a new theme/plugin) you may run out of available ‘memory’. This may be what causes the error to display.

How Much Memory Do I Need for My WordPress Website?


The default PHP memory limit for WordPress is 32MB but it’s not uncommon to need to increase it beyond this.

If you run an ecommerce store using Woocommerce for example, the recommended memory limit is 64MB to minimise the chances of your website running out of memory.

How Do I Increase My WordPress Website Memory Limit?


There are multiple different ways to increase the memory limit in WordPress, and since this is partly down to how your hosting environment is configured, there’s no surefire way to guarantee all of them will work for you. However, at least one of the following three methods should work so that you can get your site up and running again! If not, you should contact your hosting provider for further assistance.

1: Editing the wp-config.php file

The first approach we’ll be suggesting is to edit the wp_config.php file. All WordPress installations will have one of these and in order to access this you will need to access your site via an FTP Client such as Cyberduck or FileZilla.

Disclaimer: As this approach involves editing important code for your website, we recommend that you take a backup of your site, or at least the file you will be editing (wp-config.php) before attempting this method.

Firstly, connect to your site via FTP (using a client such as FileZilla or Cyberduck). If you are not sure on how to do this, please read our guide [link]here[/link]. You should then see a list of files like those in the screenshot below. If not, look for a “public_html” directory that you can click to enter.

Editing the wp-config.php file

Look for the wp-config.php file (highlighted in the above screenshot) and download this to your computer. You will then need to open this in a code/text editor with the file’s contents looking similar to this:

Editing the wp-config.php file 2

With the wp-config.php file now open in a text editor, look for WP_MEMORY_LIMIT. It will often be wrapped in parentheses with the word ‘define’ e.g. define( 'WP_MEMORY_LIMIT', '32M' );

Once found, you will need to increase the number as required. For example, you may wish to increase your memory limit to 64MB by changing ‘32M’ to ‘64M’, or to 256MB by replacing ‘32M’ with ‘256M’.

If you aren’t able to find any reference to WP_MEMORY_LIMIT in the file, this is not an immediate problem. You can just type it in as shown here above the line containing “That's all, stop editing! Happy publishing.” See the example below:

Editing the wp-config.php file 3

Once you are done with the above, save the updates you have made, and re-upload your wp-config. php file to your server via FTP. You will be asked if you wish to replace or overwrite the existing wp-config. php file, to which you should say “Yes”:

Editing the wp-config.php file 4

Now, try refreshing your website or carrying out the operation again that initially caused the “Allocated memory size exhausted” error to display to check if the issue is fixed.

2: Editing the php.ini file

If increasing the Wordpress memory limit by editing the wp-config.php file didn’t help solve your issue, the next step is to change your server settings via the php.ini file. All Wordpress sites run using PHP, so by modifying the php.ini file, we are able to change the PHP configuration for the server that powers your website.

The easiest way of doing this is via your web hosting providers control panel. Login to your account and look for ‘cPanel’ - once logged in, it should look similar to the below:

Editing the php.ini file

Within this, click on ‘MultiPHP INI Editor’:

Editing the php.ini file 2

From here, you can increase the memory limit. For example if you wanted to change your memory limit to 64MB from 32MB, enter 64M in the text box instead of 32M.

Editing the php.ini file 3

Apply the changes you have made and restart the server for the updates to take effect as shown below:

Editing the php.ini file 5

Now, try refreshing your website or carrying out the operation again that initially caused the “Allocated memory size exhausted” error to display to check if the issue is fixed.

3: Editing the .htaccess file

If your server uses Apache (which most hosting providers do), and neither of the above two methods have solved the “Allowed memory size exhausted” error, you may be able to access and edit a “.htaccess” file to resolve the problem. This is a configuration file for your server and manages many different things related to your web server including its memory limit.

In order to edit this file, you will need to connect to your web hosting platform via FTP as we did in the first approach. Navigate to the “htdocs” or “public_html” directory and look for a file called “.htaccess”.

NOTE: Some FTP clients such as Cyberduck require that you have an option called “Show Hidden Files” enabled in order to be able to see any files that begin with a ‘.’

Editing the .htaccess file

Here’s an example of what it should look like:

Editing the .htaccess file 2

Next, download a copy of the file to your computer and open it up in a text/code editor. As per our recommendation before. Please note it's always best to take a backup of your site via your hosting provider before making any changes to configuration files like this which could impact your website if something goes wrong.

With the file now open in a text editor, below the line that begins “# END WordPress” type the following: php_value memory_limit 64M - see example below:

Editing the .htaccess file 3

As with the previous methods for increasing the Wordpress memory limit, you can change ‘64’ for whatever amount of MB you wish to allocate to the website.

Once you’ve made this edit, save your changes and re-upload the file to the server (overwriting the existing .htaccess file if asked).

Final Thoughts


If you’ve carried out one or all of the above three methods for increasing the WordPress memory limit, hopefully your website is now back up and running and you can carry out the task you were originally trying to do!

That being said, the above techniques will only be able to help to a certain extent. If your website is extremely resource intensive, or has many users logged in at the same time, it might be time to upgrade your WordPress hosting plan to avoid these problems in the future. If you’re still running into memory exhaustion errors after carrying out the above, we’d recommend speaking to your web hosting provider to see what additional resources or hosting plans they can offer you.

Frequently Asked Questions


Is WordPress free?

All you need to do to use WordPress is to invest in a web hosting plan since the software itself is free.

Can I increase bandwidth?

Yes, most hosting providers allow you to increase your bandwidth with an increase in price.

Are WordPress-free themes safe?

People often think that free themes have low quality. However, free WordPress themes actually have high quality and are free to use.

Is a website on WordPress safe?

Websites on WordPress are safe, however to avoid hacking keep your website up to date.

Dylan Winn-Brown
About the Author
Dylan Winn-Brown

Dylan is the founder of Winn-Brown & Co., an agency he started at the age of 16, specializing in website development and digital transformation. Since starting the company he has worked on hundreds of projects and with clients across a broad range of industries. Now in 2022, the agency continues to service new and existing clients alongside incubating some exciting side projects.

View all posts by Dylan Winn-Brown
Discount

Enter Discount Code MOVEME During The SIGN UP Process To Get 90% Off Your First Month

with the discount code

MOVEME

Use Code Now
Jivo Live Chat