How do i change php memory limit in wordpress?

You may run into an issue when working with your WooCommerce site that asks you to increase the WordPress memory limit. The easiest way to accomplish this is by editing your wp-config.php file.

Warning: You should always backup your site before making changes to the wp-config.php file.

  1. Access files in your Managed WordPress account.
  2. Locate the file wp-config.php in the root directory or folder.
  3. Double-click the wp-config.php file to open it.
  4. Select Edit.
  5. Find the line
    /* That's all, stop editing! Happy publishing. */
  6. Right above the line in step five, add this code:
    define('WP_MEMORY_LIMIT', '256M');

  7. How do i change php memory limit in wordpress?
  8. Select Save.

More info

  • An alternate method of setting the WordPress memory limit is to edit your wp-config.php file via FTP.

1. Edit your wp-config.php file and enter something like: This increases the WP memory limit for the front-end.

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

This increases the memory limit in wp-admin.

define( 'WP_MAX_MEMORY_LIMIT', '512M' );

2. If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 64M try 256M or 512M:

memory_limit = 512M ; Maximum amount of memory a script may consume (64MB)

3. If you don’t have access to PHP.ini try adding this to an .htaccess file:

php_value memory_limit 512M

4. If none of the above works then talk to your host.

You can find more information about how to increase the memory limit in this article from WPBeginner.

Aug 23, 2022

Domantas G.

4min Read

How do i change php memory limit in wordpress?

Download Ultimate WordPress Cheat Sheet

If your WordPress website has a lot of media content or is running large scripts, you may encounter the following error message while editing it:

  • Fatal error: Allowed memory size of XXXXX bytes exhausted.
  • Fatal error: Out of memory.

This means that your WordPress code needs more memory than the given default value. However, fixing the issue is not as complicated as it might seem, and it doesn’t require any technical experience.

Read on as this article will explain what the WordPress memory limit is, how to increase it, and why you may find one of the error messages above.

  • What Is the WordPress Memory Limit?
  • How to Increase the WordPress Memory Limit?
  • How to Check the WordPress Memory Limit?
  • What Causes the “WordPress Memory Limit Exhausted” Error?

What Is the WordPress Memory Limit?

The WordPress memory limit is also known as WordPress PHP memory limit or simply PHP memory limit. It mainly sets the maximum amount of memory that a script can use on the website.

Servers store all the data and files of websites. Thus, a server must have the necessary storage capacity, processors, and RAM or memory in order to keep the site running.

The RAM capacity of a server varies depending on the hosting provider and plan used. A starter plan usually offers a low amount of RAM compared to a business or professional plan.

Every web application and function takes up some memory. The more plugins installed or media files uploaded, the more memory the site will require. If it runs out of memory, the site’s loading speed may decrease, or worse, it won’t load at all.

Hence, the WordPress memory limit is there to ensure that the website scripts don’t exceed the server’s RAM capacity.

How to Increase the WordPress Memory Limit?

By default, the memory limit is set to only 32 MB, which may not be enough for your site. However, there are several methods to increase it.

You can modify the .htaccess or wp-config.php file, set it using the hPanel PHP Configuration, or upgrade your hosting plan.

FTP

One way to edit the .htaccess or wp-config.php file is via an FTP client like FileZilla. Make sure to connect FileZilla with your site’s FTP account before continuing with one of the following tutorials:

Editing the .htaccess file

  1. Access the site’s public_html folder or root directory and find the .htaccess file.
  2. Right-click on the file and select View/Edit to be directed to the text editor.
How do i change php memory limit in wordpress?
  1. Look for the line:

# END WordPress

Add the following code beneath it:

php_value memory_limit 256M

How do i change php memory limit in wordpress?
  1. Save the file and close the editor.
  2. Click Yes when FileZilla asks whether to upload the modified file, then reload the site.

Modifying the wp-config.php file

  1. In the root folder, right-click on the wp-config.php file and select View/Edit.
How do i change php memory limit in wordpress?
  1. Find the line containing WP_MEMORY_LIMIT and change 64M to 256M.
  2. If it doesn’t exist, insert the following code above the line /* That’s all, stop editing! Happy publishing. */ or /* That’s all, stop editing! Happy blogging. */:

define ( ‘WP_MEMORY_LIMIT’, ‘256M’ );

How do i change php memory limit in wordpress?
  1. Save the changes and upload the file.

When visiting the site, you shouldn’t experience the “memory limit exhausted” error again.

File Manager

A more straightforward method to modify the .htaccess or wp-config.php file is via the file manager on your control panel. For this tutorial, we’ll be using hPanel:

  1. Access hPanel, navigate to the Files section, and select File Manager.
How do i change php memory limit in wordpress?
  1. Open the public_html folder or root directory, and double click on the .htaccess or wp-config.php file.
How do i change php memory limit in wordpress?
  1. Insert the code mentioned on the FTP tutorial based on the file chosen, then press SAVE & CLOSE when done.

Though you won’t be making any significant changes using the methods above, you should back up your site before editing it. This ensures you won’t lose your WordPress site if something goes wrong.

hPanel

An alternative solution for Hostinger clients is to set the memory limit via PHP Configuration on the hPanel:

  1. Log in to hPanel, scroll down to the Advanced section, and select PHP Configuration.
How do i change php memory limit in wordpress?
  1. Choose PHP Options and find the memory_limit field.
  2. Click on the dropdown menu and pick the highest amount.
How do i change php memory limit in wordpress?

If the memory limit is already at the maximum, then the last option is to upgrade your hosting plan to get more RAM.

For example, our WordPress Business and Pro plans provide more RAM compared to the Single and Starter plans.

How to Check the WordPress Memory Limit?

Once you’ve configured the memory limit, you might want to see if it worked. The following steps apply to users who are running WordPress 5.2 and above:

  1. Access the WordPress dashboard, hover on Tools, and select Site Health.
How do i change php memory limit in wordpress?
  1. Choose the Info tab and click on Server.
How do i change php memory limit in wordpress?
  1. Scroll down through all server settings until you find the PHP memory limit.
How do i change php memory limit in wordpress?

What Causes the “WordPress Memory Limit Exhausted” Error?

The most common cause is that the memory limit may still be set to the default value instead of the highest option. Hence, it’s important to check it before you start fixing the problem.

If that’s not the case, then you might be outgrowing the hosting resources. As your WordPress website grows, the size of its database, plus the number of scripts and files, also increases. In addition, there might be plugins or themes that need extra memory to run as well.

Hosting providers allocate only a certain amount of resources, including the RAM limit, for different types of hosting plans. When starting your WordPress journey, you might have chosen a plan with limited RAM due to affordable prices, but it might be time to upgrade it.

Other than the memory limit exhausted error, you may also encounter the following issue:

yourfile.png exceeds the maximum upload size for this site

In this case, visit our How to Increase the Maximum File Upload Size article to find solutions other than increasing the memory limit to fix that specific issue.

Conclusion

The WordPress PHP memory limit is the amount of memory available for scripts to run on your WordPress site. It ensures that the site doesn’t exceed the server’s RAM capacity given by the hosting provider.

The limit is usually set to 32 MB, which may not be enough to run a media-rich site and all its plugins. Thus, you will receive the exhausted memory error message when a script goes over the limit.

Here’s a recap on how to increase the WordPress memory limit:

  • By editing the .htaccess or wp-config.php file via an FTP or file manager.
  • Set the size limit through PHP configurations on hPanel.
  • Upgrade your hosting plan to use more resources.

Don’t be afraid to contact our customer support team if you have additional questions or if the chosen method didn’t solve the problem.

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.

How do I fix PHP memory limit in WordPress?

How to Increase the PHP Memory Limit in WordPress.
Edit your wp-config. php file..
Edit your PHP. ini file..
Edit your . htaccess file..
Use a memory increase plugin..
Contact your hosting provider..

How do I change my WordPress hosting memory limit?

Here's a recap on how to increase the WordPress memory limit:.
By editing the . htaccess or wp-config. php file via an FTP or file manager..
Set the size limit through PHP configurations on hPanel..
Upgrade your hosting plan to use more resources..

How do I increase the memory limit of a WordPress plugin?

How to Increase the WordPress PHP Memory Limit.
Edit your wp-config. ... .
If you have access to your PHP.ini file, change the line in PHP.ini. ... .
If you don't have access to PHP.ini try adding this to an .htaccess file: php_value memory_limit 512M..
If none of the above works then talk to your host..

What should PHP memory limit be set to?

A typical appropriate memory limit for PHP running Drupal is 128MB per process; for sites with a lot of contributed modules or with high-memory pages, 256MB or even 512MB may be more appropriate.