WordPress websites and business systems

How to Increase the WordPress Memory Limit

Fix "Allowed memory size exhausted" in WordPress: check your limit, raise it in your host or wp-config.php, and find what is using the memory.

Chris Eggleston
Chris Eggleston WP Mantis
Updated November 14, 2026 /  
Memory limit. Raising the WordPress memory limit safely.

You try to install a plugin, upload an image or open a page in the dashboard, and WordPress stops with a white screen or this message:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)

The numbers vary, but the meaning doesn’t: PHP hit the memory ceiling your server allows and stopped. The fix is to raise that ceiling, and if it keeps happening, to find what’s using so much memory.

Check your current limit

Go to Tools → Site Health → Info. Under Server, find PHP memory limit. Under WordPress Constants, find WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. The PHP value is the real ceiling. The WordPress constants can ask for less than that, but never more.

For most sites, 256M is plenty. WooCommerce stores, membership and course sites, and large imports may need 512M.

Fix 1: Raise it in your hosting panel

This is the cleanest fix, because it changes the actual PHP limit for your site.

  • xCloud: open the site, go to Settings → PHP Settings, set memory_limit (256M or 512M), and save.
  • Cloudways: change memory_limit in the server’s PHP settings under Settings & Packages.
  • cPanel hosts: look for Select PHP Version → Options or MultiPHP INI Editor and set memory_limit there.
  • Anything else: ask your host’s support to raise it. It takes them a minute.

Fix 2: Set the WordPress constant

If the PHP limit is already high but Site Health shows a lower WordPress value, something is asking for less. Open wp-config.php and look for these lines above /* That's all, stop editing! */:

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

WP_MEMORY_LIMIT applies to your public pages; WP_MAX_MEMORY_LIMIT applies to the dashboard and heavy tasks like image processing. Set them no higher than your PHP limit. If an old line sets a low value, change or remove it.

Fix 3: Use a .user.ini file

On hosts with no PHP settings screen, you can often set the limit yourself. Create a file named .user.ini in the same folder as wp-config.php with this line:

memory_limit = 256M

PHP reads this file every few minutes, so wait five minutes before testing. Editing .htaccess only works on Apache servers, and many modern hosts run Nginx, so .user.ini is the safer bet.

If it keeps happening, find the cause

Raising the limit treats the symptom. If a normal site needs more than 256M to load a page, a plugin is usually doing too much work. Install Query Monitor, load the page that fails, and check memory use and slow database queries by plugin. Then see whether a lighter alternative exists, or follow our plugin conflict guide to narrow it down.

Need a hand?

If the error won’t go away, or you can’t reach the dashboard to try any of this, our $79 one-time fix covers it. A developer finds the cause, fixes it, and tells you what went wrong.

Chris Eggleston
Chris Eggleston
Husband. Father to 4. Grandpa to 2. Gravity Forms enthusiast. As the owner of WP Mantis, I’m on a mission to simplify the WordPress experience for site owners. I also try to bring a unique perspective to the Gravity Forms community at gravityranger.com.
Next step Not sure what your site needs next?

We will look at it properly and tell you the five things worth doing, in order, whether or not you hire us.

Affiliate links disclaimer