WordPress "Allowed memory size exhausted" error: what it means and how to fix it

The message looks scary, but it usually has a short list of causes. Here's how to read it, raise the limit safely and find what's eating the memory.

"Fatal error: Allowed memory size of 134217728 bytes exhausted" means a piece of your WordPress site (usually a plugin, a theme or an image being processed) tried to use more server memory than PHP is allowed to give it, so PHP stopped the page. The fix is two parts: raise the memory limit to a sensible amount (256 MB is a common setting) in wp-config.php or your hosting control panel, then find out what needed that much memory, because a raised limit can hide a plugin that's misbehaving. Below are the steps we follow, in the order we'd do them.

How to read the error message

A full version of the message looks something like this:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/site/public_html/wp-content/plugins/example-plugin/includes/file.php on line 312

Three parts matter:

  • The big number is your current limit, in bytes. 67108864 is 64 MB, 134217728 is 128 MB and 268435456 is 256 MB.
  • "Tried to allocate" is the small extra amount that tipped it over, not the total the page needed. Don't read much into it.
  • The file path tells you where it happened. If it sits inside /wp-content/plugins/some-plugin-name/, that plugin is your first suspect. If it's inside /wp-content/themes/, look at the theme. A path in /wp-includes/ or /wp-admin/ only tells you WordPress core was running when memory ran out, so you'll need the steps further down.

On newer versions of WordPress you may not see this message at all. Since version 5.2, a fatal error usually shows visitors "There has been a critical error on this website" instead, and WordPress emails the site's admin address a link to recovery mode. That email often includes the same memory error, so check the inbox (and spam folder) of whatever address is set as the site admin. We cover that screen in more detail in our guide to the WordPress critical error.

Before you change anything

Take a backup, or confirm your host has a recent one you can restore. Every fix below involves editing a file on the server, and a typo in wp-config.php can take the whole site down. If you have file access through your host's file manager or SFTP, download a copy of wp-config.php before you open it.

Step 1: Check what your limit actually is

Log in to WordPress and go to Tools > Site Health > Info. Open the Server section and look for "PHP memory limit". Then open WordPress Constants and look for WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.

These are two separate limits. PHP's memory_limit is the ceiling your hosting company sets. WP_MEMORY_LIMIT is what WordPress asks for on regular pages, and it can't go above the PHP ceiling. If you can't get into the dashboard because of the error, skip to Step 2. Most hosting control panels also show the PHP memory limit on a "PHP settings" or "PHP options" screen.

Step 2: Raise the WordPress memory limit

Open wp-config.php in the main folder of your site and add this line above the comment that says /* That's all, stop editing! */:

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

Save the file and reload the page that was failing. If the error is gone, good, but keep reading, because Step 4 is still worth doing.

If nothing changed, your host's PHP ceiling is probably lower than what you asked for. WordPress can only use what PHP allows.

Step 3: Raise the PHP limit at your host

How you do this depends on the host:

  • Hosting control panel. Many hosts, including cPanel-based ones like GoDaddy, have a PHP settings or "MultiPHP INI Editor" screen where you can set memory_limit to 256M. This is the cleanest option when it's available.
  • **A php.ini or .user.ini file** in your site's main folder, with the line memory_limit = 256M. Some hosts read these files and some ignore them.
  • **.htaccess**, with php_value memory_limit 256M. This only works on certain Apache setups, and on others it causes a "500 Internal Server Error", so remove it straight away if that happens.
  • Ask the host. On managed WordPress hosting you often can't change this yourself, and a short support ticket is the fastest route.

One setting to avoid: memory_limit = -1. It removes the limit entirely, so a runaway plugin can use as much memory as the server will give it. On shared hosting that can slow down or crash the site in a different way. Pick a real number instead.

Step 4: Find out what's using the memory

Raising the limit fixes the symptom. If a single plugin is leaking memory, it'll often hit the new ceiling too, just later. Here's how we track it down:

  1. Look at the path in the error. If it names a plugin folder, start there. Check whether that plugin has an update, or whether it was updated just before the error started.
  2. Think about what just changed. A new plugin, a theme update, a PHP version change at the host or a big import are the usual triggers.
  3. Deactivate plugins one at a time. If you can't reach the dashboard, rename the plugin's folder inside /wp-content/plugins/ (for example, add -off to the end). WordPress will deactivate it. Rename it back when you're done testing.
  4. Check the error log. Most hosts keep a PHP error log in the control panel or in a file called error_log. Repeated memory errors pointing at the same file are a strong clue.
  5. Watch for heavy one-off jobs. Uploading very large photos, running a backup plugin, importing products or building reports can need much more memory than a normal page. If the error only appears during one of those, resizing photos before upload or running the job at a quiet time may be all you need.

Where we see it with LA small businesses

The pattern depends on the kind of site. Contractors, plumbers and electricians tend to upload full-size phone photos straight into project galleries, and resizing a very large image takes a lot of memory. Realtor sites often run listing or IDX plugins that pull in a lot of data at once. Law firm and accounting sites usually carry several form, booking and security plugins, and the error shows up after one of them updates. Writers, producers and entertainment sites with big media libraries can hit it while a backup or gallery plugin runs.

None of these mean the site is broken beyond repair. They mean something needs a closer look.

When to call for help

Get help if the error keeps coming back after you've raised the limit, if it names a WordPress core file and you can't find a plugin cause, or if you're not comfortable editing server files. It's also worth a second look if your host has a low PHP limit you can't raise, because that may be a sign the hosting plan doesn't fit the site anymore.

KeptWeb's WordPress maintenance covers plugin and theme updates, and our monitoring watches whether your site is up so problems like this get noticed. If the site needs a fresh start instead, see our website building packages. We work with contractors, attorneys, accountants, realtors and other small businesses in Los Angeles.

Not sure what's behind the error? Ask for our free website review and we'll take a look and tell you what we find. Plans are Basic $49/mo, Growth $99/mo and Pro $149/mo, month-to-month. See our plans.

Site broken right now? Start with our website help guides, including WordPress "critical error" fix or Website down? What to do first. If you aren't on a KeptWeb plan, our one-time Fix it now service is $149; you can tell us what's wrong first. Support hours are Mon–Fri, 9 am–5 pm PT.

Related reading