WordPress Memory Limit: How To Fix PHP Memory Limit

WordPress Memory Limit: How To Fix PHP Memory Limit

WordPress Memory Limit: How To Fix PHP Memory Limit - If your WordPress website contains a large amount of media content or is running large

WordPress Memory Limit: How To Fix PHP Memory Limit – If your WordPress website contains a large amount of media content or is running large scripts.

Also read: 17 Effective Ways to Speed Up WooCommerce (2023)

You may see the following error message while editing it:

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

This indicates that your WordPress code requires more memory than the default value. However, resolving the problem is not as difficult as it appears, and no technical knowledge is required.

WordPress Memory Limit: How To Fix PHP Memory Limit

Continue reading to learn about the WordPress memory limit, how to increase it, and why you might see one of the error messages listed above.

What Is WordPress’s Memory Cap?

WordPress memory limits are also referred to as WordPress PHP memory limits or simply PHP memory limits. It primarily determines how much memory a script can use on the website.

Servers house all of a website’s data and files. Thus, in order to keep the site running, a server must have sufficient storage capacity, processors, and RAM or memory.

Also read: How To Fix Installation Failed: Destination Folder Already Exists

A server’s RAM capacity varies depending on the hosting provider and plan used. In comparison to a business or professional plan, a starter plan typically provides less RAM.

Each web application and function consumes memory. The more plugins you install or media files you upload, the more memory your site will need. If it runs out of memory, the site’s loading speed may slow down, or it may not load at all.

As a result, the WordPress memory limit exists to ensure that the website scripts do not exceed the RAM capacity of the server.

How Can I Increase WordPress’s Memory Limit?

The memory limit is set to 32 MB by default, which may be insufficient for your site. However, there are several ways to boost it.

Also read: How To Use WordPress Lazy Load On Your Website

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


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

Editing .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.
  3. Look for the line:
    # END WordPress

    Add the following code beneath it:

    php_value memory_limit 256M
  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.
  2. Find the line containing WP_MEMORY_LIMIT and change 64M to 256M.
  3. 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’ );
  4. 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. We’ll be using hPanel for this tutorial:

  1. Access hPanel, navigate to the Files section, and select File Manager.
  2. Open the public_html folder or root directory, and double click on the .htaccess or wp-config.php file.
  3. Insert the code mentioned on the FTP tutorial based on the file chosen, then press SAVE & CLOSE when done.

Though the methods described above will not result in significant changes, you should back up your site before making any changes. This ensures that your WordPress site will not be lost if something goes wrong.


Setting the memory limit via PHP Configuration on the hPanel is an alternative solution for Hostinger clients:

  1. Log in to hPanel, scroll down to the Advanced section, and select PHP Configuration.
  2. Choose PHP Options and find the memory_limit field.
  3. Click on the dropdown menu and pick the highest amount.

If the memory limit has already been reached, your only option is to upgrade your hosting plan to get more RAM.

Also read: How To Send Emails For Free Using The Gmail SMTP Server

Our WordPress Business and Pro plans, for example, include more RAM than the Single and Starter plans.

What is the WordPress Memory Limit?

After you’ve set the memory limit, you might want to test it. Users running WordPress 5.2 and higher should take the following steps:

  1. Access the WordPress dashboard, hover on Tools, and select Site Health.
  2. Choose the Info tab and click on Server.
  3. Scroll down through all server settings until you find the PHP memory limit.

What Is the Root Cause of the “WordPress Memory Limit Exhausted” Error?

The most common reason for this is that the memory limit is still set to the default value rather than the highest option. As a result, it’s critical to double-check it before attempting to resolve the issue.

If this is not the case, you may have outgrown your hosting resources. The size of your WordPress website’s database, as well as the number of scripts and files, grows as it grows. Furthermore, there may be plugins or themes that require additional memory to function.

Also read: How To Fix WordPress Error Establishing A Database Connection

For different types of hosting plans, hosting providers only allocate a certain amount of resources, including the RAM limit. You may have started your WordPress journey with a plan with limited RAM due to low prices, but it may be time to upgrade.

Aside from the memory limit exhausted error, you might also encounter the following problem:

yourfile.png is larger than the maximum upload size for this site.

In this case, see our How to Increase the Maximum File Upload Size article for alternatives to increasing the memory limit to resolve the issue.


The amount of memory available for scripts to run on your WordPress site is defined as the WordPress PHP memory limit. It ensures that the site does not exceed the RAM capacity of the server as specified by the hosting provider.

Also read: What Is FTP: An Introduction To FTP For Beginners

The default limit is 32 MB, which may not be enough to run a media-rich site and all of its plugins. When a script exceeds the limit, you will receive the exhausted memory error message.

Here’s a quick rundown of how to increase WordPress’s memory limit:

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

If you have any further questions or if the method you chose did not solve the problem, please do not hesitate to contact our customer support team.

The WordPress Learning Hub

Related Posts