Back to Community

How to Fix Common WordPress Localhost Memory and Upload Limit Errors

24 threads Sep 7, 2025 CoreLocalhost installs

Content

Running WordPress on a local development environment like XAMPP, WAMP, or MAMP is incredibly useful, but it often comes with a specific set of errors related to PHP configuration. Two of the most frequent and frustrating issues are the "Allowed memory size exhausted" fatal error and the "upload_max_filesize" limit being exceeded. This guide will explain why these errors happen on localhost and provide the most effective solutions.

Why Do These Errors Happen on Localhost?

Local server stacks like XAMPP, WAMP, and MAMP come with conservative default PHP settings designed for a generic environment. When you start developing a WordPress site, especially with resource-intensive themes, plugins, or large import files, these defaults can quickly be exceeded. The errors are not caused by WordPress itself but by the underlying PHP configuration on your local machine.

Solution 1: Fixing "Allowed memory size exhausted" Errors

This fatal error indicates that a PHP script has hit the maximum amount of memory it is allowed to use. The solution is to increase the PHP memory limit. It's crucial to edit the correct php.ini file that your local server is actually using.

  1. Find the Correct php.ini File: The easiest way to find the active php.ini file is to create a simple info.php file in your local site's root directory (e.g., xampp/htdocs/your-site/). Add this code to the file:
    <?php phpinfo(); ?>
    Open this file in your browser (e.g., http://localhost/your-site/info.php) and search for the "Loaded Configuration File" row. This shows the exact path to the php.ini file you need to edit.
  2. Edit the php.ini File: Open the specified php.ini file in a text editor like Notepad++.
    • Search for the line: memory_limit = 128M (the value may be different).
    • Change it to a higher value, such as: memory_limit = 512M or memory_limit = 1024M.
    • Save the file.
  3. Restart Your Local Server: For the changes to take effect, you must completely restart Apache (or your entire WAMP/MAMP stack).

Note: While you can also try to set the memory limit in wp-config.php by adding define('WP_MEMORY_LIMIT', '512M');, editing php.ini is the more reliable and fundamental solution for localhost environments.

Solution 2: Increasing the Maximum File Upload Size

The error "The uploaded file exceeds the upload_max_filesize directive in php.ini" means your theme or plugin zip file is larger than the allowed limit. To fix this, you need to adjust two related settings in the same php.ini file.

  1. Edit the Correct php.ini File: Use the method described above to locate the correct file.
  2. Change the Key Values: Find and modify the following lines. Ensure post_max_size is larger than upload_max_filesize.
    upload_max_filesize = 64M
    post_max_size = 128M
    max_execution_time = 300
  3. Restart Your Local Server: Always restart your server after making changes.

Alternative .htaccess Method (if supported): If your local Apache setup allows it, you can add these lines to your .htaccess file in the WordPress root directory. However, this is often less reliable on localhost than directly editing php.ini.

php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value memory_limit 512M
php_value max_execution_time 300
php_value max_input_time 300

Solution 3: Troubleshooting Persistent Memory Exhaustion

If you have already increased the memory limit to a very high value (e.g., 512MB or 1GB) and are still getting fatal errors, especially ones that try to allocate a ridiculously large number of bytes, the problem is likely a code error and not a configuration issue.

  1. Check for Plugin/Theme Conflicts: A memory leak or infinite loop in a plugin or theme is a common cause. Disable all plugins and switch to a default theme like Twenty Twenty-One. If the error disappears, reactivate your plugins and theme one by one to identify the culprit.
  2. Review Custom Code: If you are developing your own theme or plugin, carefully check any custom code you've recently added, especially in functions.php or within custom plugin files, for infinite loops or recursive functions.

Important Final Checks

  • After making any changes to php.ini, always use your info.php file to verify that the new values are active.
  • Remember that localhost performance can be significantly slower than a live server, especially if you are using a traditional hard drive (HDD) instead of a solid-state drive (SSD). Slow database operations can sometimes manifest as timeout errors that resemble memory issues.
  • If you are migrating a site from a live server to localhost and encounter these errors, the 'Localhost Installs' team suggests following the conflict diagnosis steps above, as the problem often lies in copied-over plugins or themes that behave differently in the new environment.

By correctly modifying your local server's PHP configuration and systematically diagnosing conflicts, you can resolve these common errors and get back to developing your WordPress site smoothly.

Related Support Threads Support