How to Fix the WordPress “Allowed Memory Size Exhausted” Error (2026)

If your WordPress site is showing “Fatal error: Allowed memory size of X bytes exhausted,” your site has hit the memory limit set for PHP. This is a simple fix once you know where that limit actually lives — here’s exactly how to raise it and when it signals a bigger problem worth fixing instead.

What Causes This Error

Every WordPress site runs on PHP, and PHP is given a maximum amount of memory (“RAM”) it’s allowed to use per request. When a plugin, theme or import process needs more memory than that limit allows, PHP stops and WordPress shows this fatal error instead of the page.

Step-by-Step Fix

1. Raise the Memory Limit in wp-config.php

Open wp-config.php and add this line just above the /* That's all, stop editing! */ comment:

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

This raises the limit WordPress itself requests. If you manage the wp-admin side specifically, you can also set:

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

2. Raise It at the Server Level (If Step 1 Doesn’t Work)

Some hosts cap PHP memory at the server level, which overrides what wp-config.php requests. If the error persists, add this to a file named .htaccess in your site’s root folder:

php_value memory_limit 256M

On hosts running PHP-FPM, this line in .htaccess won’t work — instead, look for a php.ini file in your hosting control panel, or ask your host to raise the limit for your account. Most managed WordPress hosts have a simple PHP settings panel for exactly this.

3. Check If a Specific Plugin Is the Real Cause

If you only hit this error during a specific action — importing a large file, running a backup, or using a particular plugin — raising the limit is a real fix, not a workaround. But if memory keeps climbing over time with no clear trigger, that usually points to a memory leak in a specific plugin. Deactivate plugins one at a time (renaming their folders via FTP works without needing admin access) to isolate which one is responsible.

How Much Memory Does a WordPress Site Actually Need?

A simple WordPress site with a handful of plugins is usually fine at 128M–256M. Sites running WooCommerce, page builders, or several SEO/caching plugins together often need 256M–512M. If you’re regularly needing more than that, it’s worth asking whether every active plugin is actually necessary.

Frequently Asked Questions

Is raising the memory limit safe?

Yes — within reason. It simply allows PHP to use more of the server’s available RAM; it doesn’t change how your site works otherwise.

Why does WP_MEMORY_LIMIT not work on my host?

Some hosting environments enforce a hard server-side cap that WordPress constants can’t override. In that case, the fix has to happen in your hosting account’s PHP settings, not in wp-config.php.

Preet Kalirona

Written & Reviewed By

Preet Kalirona

WordPress & SEO educator with 12+ years of experience, founder of Preet Web Vision, and creator of the Preet Tech Ideas YouTube channel.

Scroll to Top