Fixing the WordPress Memory Exhausted Error: Increase PHP Memory

#Errorfix #Tutorial #WordPress

Encountering a memory exhausted error in WordPress can be a daunting experience. This error typically occurs when a WordPress script exceeds the default PHP memory limit, disrupting site functionality and preventing access. Fortunately, increasing the PHP memory limit is a straightforward process that can resolve this issue, ensuring your WordPress site runs smoothly. This guide will walk you through the steps to increase your PHP memory limit, effectively solving the memory exhausted error.

Understanding the Memory Exhausted Error

The memory exhausted error often appears as a fatal error message stating, “Allowed memory size of XXXXXX bytes exhausted,” followed by the file path causing the error. This message indicates that a specific script has surpassed the allocated memory limit, leading to a halt in execution.

Steps to Increase PHP Memory Limit

1. Modify the wp-config.php File

One of the most effective methods to increase the PHP memory limit is by editing the wp-config.php file.

  • Access Your Site Files: Use an FTP client or your hosting account’s file manager to access your WordPress site’s files.
  • Edit wp-config.php: Locate the wp-config.php file in the root directory. Open it in a text editor.
  • Increase Memory Limit: Add the following line of code within the main PHP tags:
    define('WP_MEMORY_LIMIT', '256M');
    This line increases the PHP memory limit to 256MB, which should suffice for most WordPress sites. Adjust the value accordingly based on your needs and host’s policies.

2. Update the PHP.ini File

If modifying wp-config.php doesn’t resolve the error, you might need to edit the php.ini file directly. This file is the default configuration file for PHP and controls many PHP settings.

  • Locate PHP.ini: This file is usually found in the root directory or within a folder named etc or php in your server’s file system. Access might vary based on your hosting environment.
  • Edit PHP.ini: Look for the line memory_limit and change its value:
    memory_limit = 256M
  • Save Changes: After editing, save the file and re-upload it if necessary.

3. Modify the .htaccess File

Another approach involves editing the .htaccess file, especially if you don’t have access to php.ini.

  • Access .htaccess: Find the .htaccess file in the root directory of your WordPress installation.
  • Increase Memory Limit: Add the following line at the end of the file:
    php_value memory_limit 256M
  • Save and Upload: Save your changes and ensure the file is correctly uploaded back to your server.


Increasing the PHP memory limit in WordPress can effectively resolve the memory exhausted error, improving your site’s performance and stability. While the wp-config.php method is generally the most straightforward, you might need to explore alternative approaches depending on your hosting environment and access permissions. Always back up your site before making any changes to critical files like wp-config.php, php.ini, or .htaccess. If you’re unsure about making these changes yourself, consider reaching out to your hosting provider for assistance.

Recommended for further reading

WPKoi Templates
for Elementor

300+ stunning full page templates for Elementor to Elevate Your Website

WPKoi Templates for Elementor

Block themes

Wwwows WordPress themes are new generation block based themes with all full site editing features You need.

Wwwows block based WordPress themes