+8801928835756
Back to Blog
WordPress Development 6 min read 23 views

WordPress Memory Limit Error Solution

IM

Ibrahim Monir

Full-Stack Developer

Jul 9, 2026
WordPress Memory Limit Error Solution

Fix the WordPress "Allowed memory size exhausted" error by increasing the PHP memory limit — via wp-config.php, php.ini, .htaccess, or your host. Recommended value, causes, and FAQ.

If your site suddenly shows "Fatal error: Allowed memory size of XXXXXX bytes exhausted" — or a blank page after uploading an image or activating a plugin — you've hit the WordPress memory limit error. It means PHP ran out of the memory it's allowed to use. The good news: it's one of the easiest WordPress errors to fix, and you have several ways to do it. Here's the complete solution.

Quick answer: Fix the WordPress memory limit error by increasing PHP's memory allocation. Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php. If that isn't enough, also raise memory_limit in php.ini or .htaccess, or ask your host to increase it. Most sites run comfortably at 256M.

What is the WordPress memory limit error?

Every WordPress site runs on PHP, and PHP is given a fixed amount of memory (RAM) to build each page. The memory limit caps how much a single script can use. When a plugin, theme, or process needs more than that cap, PHP stops and throws the "allowed memory size exhausted" error — sometimes as a visible message, sometimes as a blank white screen.

The typical error looks like this:

Fatal error: Allowed memory size of 67108864 bytes exhausted
(tried to allocate 2097152 bytes) in /home/site/public_html/wp-includes/...

That 67108864 is 64MB — a common (and often too low) default.

What causes it?

  • A low default memory limit from your host (often 64MB or less).
  • Heavy plugins — page builders, WooCommerce, backup and import tools.
  • Large image uploads that need memory to process and resize.
  • Many plugins running at once, each adding to the total.
  • Import or migration tasks that process a lot of data in one request.

Solution 1: Increase the limit in wp-config.php (easiest)

This is the first thing to try and it fixes most cases. Open wp-config.php in your site's root folder (via your host's file manager or FTP) and add this line above the "That's all, stop editing!" comment:

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

Save, then reload your site. If you also hit the limit inside the admin area (during imports or updates), raise the admin limit too:

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

Note: WP_MEMORY_LIMIT can only raise the limit up to what your server allows. If your host caps PHP memory below this, use Solution 2 or 3.

Solution 2: Increase memory_limit in php.ini

If editing wp-config.php doesn't stick, change PHP's setting directly. Many hosts expose PHP settings in the control panel (cPanel → "Select PHP Version" / "PHP Options" / "MultiPHP INI Editor") where you can set:

memory_limit = 256M

If you have access to a php.ini file in your site root, add the same line there. This sets the ceiling that WP_MEMORY_LIMIT is allowed to reach.

Solution 3: Increase it via .htaccess

On Apache servers, you can raise the limit in your .htaccess file (in the site root). Add:

php_value memory_limit 256M

Only use this if your host allows php_value directives — on some servers it causes a 500 error, in which case simply remove the line and use another solution.

Solution 4: Ask your host (or upgrade hosting)

Some managed and shared hosts lock PHP memory at the server level, so none of the above will exceed their cap. In that case, contact your host and ask them to raise your memory_limit to 256M — a reasonable request they can usually do in seconds. If you're constantly hitting limits on cheap shared hosting, it's a sign to move to a better plan or a quality WordPress host.

How to check your current memory limit

Not sure what you're working with? WordPress shows it for you. Go to Tools → Site Health → Info → Server and look for "PHP memory limit." Check it before and after your change to confirm the new value took effect.

Which value should you use?

Memory limit Good for
64M Bare minimum — often too low, causes errors
128M Simple blogs and small sites
256M Recommended default for most sites
512M+ WooCommerce, large sites, heavy imports

Don't set it absurdly high "just in case" — an unusually high limit can hide a memory leak or a badly coded plugin that's the real problem. 256M is the sweet spot for most sites.

Still getting the error? Find the real cause

If you've raised the limit and it still crashes, something is consuming too much memory. Track it down:

  • Deactivate plugins one by one — find the memory-hungry one.
  • Switch to a default theme temporarily to rule out theme code.
  • Enable WP_DEBUG to log the exact file and line hitting the limit.
  • Check for a plugin loop or leak — a badly coded plugin can consume memory endlessly no matter how high you set the cap.

Frequently asked questions

How do I increase the memory limit in WordPress?

Add define( 'WP_MEMORY_LIMIT', '256M' ); to your wp-config.php file, above the "stop editing" line. If your host caps PHP memory lower, also set memory_limit = 256M in php.ini or your hosting control panel, or ask your host to raise it.

What is a good memory limit for WordPress?

256M is the recommended memory limit for most WordPress sites. Simple blogs can run on 128M, while WooCommerce stores, large sites, and heavy import tasks may need 512M or more. WordPress itself recommends at least 128M.

Why does my WordPress memory limit keep getting exhausted?

If the error returns even after raising the limit, a plugin or theme is consuming excessive memory — often a page builder, backup tool, or a badly coded or leaking plugin. Deactivate plugins one by one and enable WP_DEBUG to find the exact cause instead of just raising the cap higher.

Can increasing the memory limit break my site?

No. Raising the PHP memory limit to a reasonable value like 256M is safe and simply lets your site use more memory when it needs it. The only caveat is that a php_value line in .htaccess can cause a 500 error on some servers — if that happens, remove the line and use another method.

Final thought

The WordPress memory limit error looks scary but is genuinely simple to fix: give PHP more memory. Start with WP_MEMORY_LIMIT in wp-config.php, move up to php.ini or your host if needed, and settle on 256M for most sites. And if it keeps coming back, don't just keep raising the number — find the plugin that's eating your memory and fix the root cause.

Fighting a memory error that won't go away? Get in touch and I'll find what's draining your site's memory and fix it properly.

More from WordPress Development

Related Posts