Skip to content
WordPress

WordPress Memory Exhausted: Raising the PHP Limit

Learn how to fix the WordPress memory exhausted error by identifying memory limits, resolving plugin and theme issues, and preventing future resource exhaustion.

WordPress Memory Exhausted: Raising the PHP Limit

The WordPress memory exhausted error appears when a PHP process runs out of the memory allocated to it before finishing its job. The full message usually reads something like: “Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /home/user/public_html/wp-includes/…” It looks technical and alarming, but the WordPress memory exhausted error is one of the most straightforward WordPress problems to fix. The solution in the majority of cases is simply increasing the memory limit — either in WordPress, in PHP, or at the server level depending on your hosting environment. This guide walks through every method, from the simplest one-line fix to the server-level configuration changes needed on some hosts, and explains how to prevent the WordPress memory exhausted error from returning. If you want the full context, see our WordPress Errors Complete Guide.

Understanding What the WordPress Memory Exhausted Error Is Telling You

PHP, the language WordPress runs on, is allocated a fixed amount of server memory to work with on each request. When WordPress loads a page, it executes PHP code that uses that memory — loading the WordPress core, activating plugins, running theme functions, and querying the database. The WordPress memory exhausted error occurs when the total memory required for all of these operations exceeds the limit that PHP has been given.

The error message contains two useful pieces of information: the current memory limit (the first number, converted from bytes) and the location of the code that exceeded it. A limit of 134217728 bytes is 128 megabytes. If the error says WordPress tried to allocate additional bytes inside a specific plugin file, that plugin is the operation that pushed memory over the edge — though it is often not the plugin’s fault, just the straw that broke the camel’s back. The WordPress memory exhausted error typically means the total memory being used was already close to the limit, and one final allocation pushed it over.

WordPress itself recommends a minimum of 64 MB PHP memory for basic sites and 256 MB for sites running WooCommerce, page builders like Elementor or Divi, or any combination of several active plugins. Sites with large product catalogues, heavy caching plugins, or complex custom queries often need 512 MB to function reliably without hitting the WordPress memory exhausted error. The default PHP memory limit on many shared hosting accounts is 64 MB or 128 MB — adequate for minimal WordPress installations but often too low for real-world sites with any meaningful plugin setup.

Fix 1 — Increase the Memory Limit in wp-config.php

This is the fastest fix for the WordPress memory exhausted error and works on most hosting environments. Open wp-config.php via FTP or your hosting file manager and add this line directly before the line that reads “That’s all, stop editing! Happy publishing.”:

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

Save the file and reload the page that was showing the WordPress memory exhausted error. In most cases this resolves it immediately. WordPress passes this value to PHP as the memory limit for WordPress processes, overriding the default server limit — up to the maximum the server allows. If 256M does not clear the WordPress memory exhausted error, increase to 512M:

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

If you are running a multisite installation or need to increase memory for the WordPress admin specifically (backend operations like bulk actions or plugin installations hit their own limit), add this line alongside the above:

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

Note that the WP_MEMORY_LIMIT constant only works up to whatever PHP’s own server-level limit allows. If the server’s PHP memory cap is set to 128M and you set WP_MEMORY_LIMIT to 512M, the server cap wins and the WordPress memory exhausted error will persist. In that case, proceed to the fixes below.

Fix 2 — Set the PHP Memory Limit in .htaccess or php.ini

If the wp-config.php change does not resolve the WordPress memory exhausted error, the PHP memory limit needs to be set at a lower level — either in .htaccess or in php.ini depending on what your server permits.

For .htaccess (Apache servers on shared hosting), open the .htaccess file in your WordPress root and add:

php_value memory_limit 256M

For php.ini (available on some shared hosts and most VPS environments), create or edit a php.ini file in your WordPress root and add:

memory_limit = 256M

These methods set the memory limit at the PHP level rather than within WordPress, which means they work even when wp-config.php changes are being overridden by server configuration. Reload the page showing the WordPress memory exhausted error and confirm whether it has cleared. On hosts using FastCGI or PHP-FPM, a server restart may be required before the change takes effect — contact your hosting support if the setting appears to be ignored.

Fix 3 — Identify and Address the Memory-Heavy Plugin or Theme

Increasing the memory limit fixes the immediate WordPress memory exhausted error, but it does not address why memory consumption was high enough to hit the limit in the first place. A plugin or theme with a memory leak — where it allocates memory without releasing it properly — will eventually exhaust even a generous limit. Identifying the memory-heavy component is worth doing after the immediate error is resolved.

The Query Monitor plugin (free; available from the WordPress plugin repository) shows per-request memory usage broken down by hook and plugin. Install Query Monitor, reload the page that was showing the WordPress memory exhausted error, and look at the memory usage column in the Hooks panel. Plugins that consume significantly more memory than others are candidates for replacement or optimisation.

A simpler approach: deactivate plugins one at a time and check how much memory usage drops after each deactivation. On a test or staging site, this can be done via the plugin list in wp-admin. On a live site that is producing the WordPress memory exhausted error on the front end, use FTP to rename plugin folders in wp-content/plugins/ one at a time, monitoring memory use with Query Monitor or the PHP memory values that appear when WP_DEBUG is enabled. The plugin whose deactivation produces the largest memory drop is the one most responsible for pushing your site toward the WordPress memory exhausted error threshold.

Fix 4 — Contact Your Host About Server-Level Memory Limits

On some shared hosting plans, the server-level PHP memory limit is set so low — 32 MB or 64 MB — that no amount of wp-config.php or .htaccess changes can override it. These hosts enforce their memory limit at the server configuration level, and the WordPress memory exhausted error persists regardless of what you set in WordPress. This is a hosting plan limitation, not a WordPress or site configuration problem.

Contact your host’s support and specifically ask them to increase the PHP memory limit for your account to at least 256 MB. Most reputable hosts will do this at no extra charge on plans that advertise WordPress compatibility — a 256 MB PHP memory limit is effectively a minimum requirement for running a functional WordPress site with plugins. If the host refuses or cannot increase the limit, it is a strong signal that the plan is underspecified for WordPress and that upgrading to a VPS or a WordPress-specific managed plan is the correct long-term solution.

Preventing the WordPress Memory Exhausted Error

The WordPress memory exhausted error tends to appear suddenly on sites that have been accumulating plugins over time, each one adding a small memory overhead until a threshold is crossed. Prevention is straightforward once the pattern is understood.

Audit your installed plugins periodically and deactivate anything that is not actively used. A deactivated plugin consumes no PHP memory at runtime, so ten unused plugins sitting in your plugins directory cost you nothing — but ten active plugins all loading their code on every request contribute meaningfully to your total memory footprint. Run each remaining plugin through a memory check with Query Monitor annually and replace any that consume disproportionate memory with lighter alternatives that achieve the same function.

Set your PHP memory limit proactively rather than reactively. If your site is currently running fine at 128M but growing in complexity, raising to 256M before the WordPress memory exhausted error appears is better than waiting for the error to surface during a traffic spike. Most hosting plans allow this without support intervention, and the cost of a few extra megabytes of PHP memory is negligible compared to the disruption of the WordPress memory exhausted error hitting a live site.

Our guide on how to increase WordPress memory limit safely goes deeper on each configuration method and covers the edge cases — multisite memory limits, WP-CLI memory allocation, and object cache memory considerations — that this guide touches on in summary. Our guide on fixing the WordPress maximum execution time exceeded error covers the related PHP resource limit error that often appears alongside the WordPress memory exhausted error on under-resourced hosting plans. The WordPress wp-config.php developer documentation lists every available constant including the memory limit options and their accepted values. You might also run into WordPress Upload Size Limit.

Nikolas Lamprou

Nikolas Lamprou (MSc; GCFR, SC-200, Security+) has been working with computers professionally since 2009 — starting with web development and e-commerce, and moving into cybersecurity over the years. Based in Greece, he brings over 15 years of real-world IT experience to SolveTechToday, where he writes about Windows fixes, software reviews, security tools, and AI applications. His goal is straightforward: cut through the noise and give readers clear, honest guidance on the tech decisions that matter.

Stay Ahead

Fix your next problem before it starts

Get the week's best Windows fixes, software picks, and security guides delivered straight to your inbox. No noise, just solutions.

Press ESC to close · Try "Windows 11" or "Chrome"