Your site was running fine, then one page (or the whole dashboard) dies with a line like this: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes). The WordPress memory exhausted error looks scary, but it’s one of the most honest errors PHP can throw: it tells you exactly what happened, and usually points to where it happened.
The quick fix is raising the memory limit. The real fix is figuring out why WordPress needed that much memory in the first place. This guide covers both, in the order you should actually do them.
What Does “Allowed Memory Size Exhausted” Mean in WordPress?
The “allowed memory size exhausted” error means a PHP script on your WordPress site tried to use more memory than the server permits for a single request, so PHP killed the request. The number in the message is the current limit in bytes, and the file path at the end shows where the script was when memory ran out.
Every time someone loads a WordPress page, PHP loads WordPress core, your theme, and every active plugin into memory. Each request gets a fixed memory budget. Blow past that budget and PHP stops dead instead of letting one request eat the whole server.
The byte number in the error translates to a familiar limit:
41943040bytes = 40M (WordPress’s default single-site value)67108864bytes = 64M134217728bytes = 128M268435456bytes = 256M
The “tried to allocate” part is usually tiny, because it’s just the last straw. The memory was already used up by everything that ran before it.
One catch: on modern WordPress you often won’t see this message on screen at all. Since WordPress 5.2, fatal errors show the generic “There has been a critical error on this website” page instead, and the real message lands in your error log or the recovery mode email sent to the admin address. If that’s what you’re seeing, the WordPress critical error fix guide covers how to get the full error out of hiding.
Why Is My WordPress Site Running Out of Memory?
A WordPress site runs out of memory for one of two reasons: the memory limit is set too low for what the site legitimately does, or something on the site is wasting memory. Raising the limit fixes the first problem. It only hides the second one.
The common causes, roughly from most to least likely:
- A limit that’s too low for the stack. WordPress core alone is light, but page builders and WooCommerce are not. According to WooCommerce’s own server recommendations, stores should have a WordPress memory limit of 256 MB or greater. Elementor’s system requirements list 256 MB as the minimum and 512 MB as recommended.
- A plugin or theme with a memory leak. A badly written query that loads thousands of posts at once, or a loop that never ends, will exhaust any limit you give it.
- Heavy admin tasks. Importing a big XML file, regenerating thumbnails, or processing a huge image upload can spike memory far above normal page loads.
- Bloated autoloaded options. WordPress loads every “autoloaded” option on every single request. Leftover plugin data stuffed into autoload inflates memory use on every page.
Step 1: Check Your Current WordPress Memory Limit
Check your current memory limits in WordPress under Tools > Site Health > Info. The “Server” section shows the PHP memory limit set by your host, and the “WordPress Constants” section shows WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.
You need both numbers because WordPress and PHP each have their own limit:
- PHP memory_limit is the hard ceiling set by the server. Nothing in WordPress can go above it.
- WP_MEMORY_LIMIT is what WordPress asks for on front-end requests. By default, WordPress tries to raise memory to 40MB for a single site and 64MB for multisite.
- WP_MAX_MEMORY_LIMIT is what WordPress asks for during admin tasks like updates and image processing. It defaults to 256MB.
If the error is so bad you can’t reach wp-admin, skip ahead: the fixes in steps 2 to 4 all work over FTP or your hosting file manager.
Step 2: Increase the WordPress Memory Limit in wp-config.php
The fastest way to increase the WordPress memory limit is to define WP_MEMORY_LIMIT in wp-config.php. Open the file in your site’s root folder and add this line above /* That's all, stop editing! Happy publishing. */:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );Save the file and reload the page that was failing. If the error is gone, check Site Health again to confirm the new value actually took.
Placement matters. If you add the define below the “stop editing” line, WordPress has already loaded its settings and your value gets ignored. This is the single most common reason “I added it and nothing changed.”
The other common reason: the server’s PHP memory_limit is lower than what you asked for. If your host caps PHP at 128M, setting WP_MEMORY_LIMIT to 256M does nothing. That’s when you move to step 3.
Step 3: Raise the PHP Memory Limit on the Server
When wp-config.php isn’t enough, the PHP memory limit itself has to be raised at the server level, through your hosting control panel, a php.ini or .user.ini file, or .htaccess. Which one works depends on how your host runs PHP.
Hosting control panel (try this first). In cPanel, look for “MultiPHP INI Editor” or “Select PHP Version” > Options, and set memory_limit to 256M. Most managed hosts have a similar PHP settings screen. This is the cleanest option because the host applies it correctly for your setup.
php.ini or .user.ini. On hosts running PHP-FPM or CGI, create or edit a .user.ini file (or php.ini, depending on the host) in your site root with:
memory_limit = 256MChanges to .user.ini can take a few minutes to apply, because PHP caches the file. Don’t assume it failed after one refresh.
.htaccess. On Apache servers running PHP as a module (mod_php), you can add this to .htaccess:
php_value memory_limit 256MBe careful with the .htaccess method. On servers running PHP-FPM, php_value isn’t supported and the line itself triggers a server error. If your site switches from a memory error to a blank “Internal Server Error” after this edit, remove the line immediately. The WordPress 500 internal server error guide explains why .htaccess edits cause that.
Which Memory Limit Method Should You Use?
| Method | What it changes | Works when | Risk |
|---|---|---|---|
| wp-config.php (WP_MEMORY_LIMIT) | What WordPress requests | Server PHP limit is already high enough | Very low |
| Hosting panel (cPanel, etc.) | Server PHP memory_limit | Host exposes PHP settings | Very low |
| php.ini / .user.ini | Server PHP memory_limit | PHP-FPM or CGI hosting | Low |
| .htaccess (php_value) | Server PHP memory_limit | Apache with mod_php only | Can cause a 500 error |
| Ask your host | Account-level limit | Host enforces a hard cap | None |
Step 4: Ask Your Host If Nothing Changes
If Site Health still shows the old PHP memory limit after trying every method, your host is enforcing a hard cap that only they can change. Open a support ticket or live chat and ask them to raise memory_limit for your account to 256M.
If the host refuses, or 256M is only available on a more expensive plan, that’s useful information. A WooCommerce store or Elementor site that doesn’t fit inside its host’s memory cap has outgrown that hosting plan, and no amount of wp-config.php tweaking will change that.
Step 5: Find What’s Actually Eating the Memory
Raising the memory limit makes the WordPress memory exhausted error go away, but if a plugin is leaking memory, the error will come back as soon as the site grows. The real fix is finding which plugin, theme, or task uses the memory, and there are three good places to look.
Read the file path in the error. If the path points into /wp-content/plugins/some-plugin/, that plugin is a strong suspect. Treat it as a lead, not proof: the path shows where memory ran out, which isn’t always the code that used it up.
Measure with Query Monitor. The free Query Monitor plugin shows peak memory usage for every page load in the admin toolbar. Compare a simple page with the one that crashes. If a normal page uses 30MB and the product archive uses 240MB, you know exactly where to dig.
Deactivate and test. Turning plugins off one at a time is still the most reliable way to catch the culprit. The full process, including how to do it without taking the live site down, is in the guide on how to find which WordPress plugin is causing a problem.
Also check your autoloaded options. Recent WordPress versions include a Site Health check that flags large amounts of autoloaded data, and old plugins often leave megabytes of junk behind after you delete them. A proper WordPress database cleanup trims that dead weight so every request starts lighter.
How Much Memory Does a WordPress Site Actually Need?
Most WordPress sites run well with a 128M to 256M memory limit. A simple blog or brochure site is comfortable at 128M, while WooCommerce stores and page-builder sites should start at 256M, and large stores or membership sites may need 512M.
Here’s the contrarian part: don’t set the limit to 1024M, 2048M, or -1 (unlimited) “just to be safe.” The memory limit is per request, not per site. On a server handling many requests at once, a huge limit lets one runaway process hog RAM that every other visitor needs. On shared hosting, that can get your account throttled or suspended.
A sensible memory limit also works as an early-warning system. When a plugin update suddenly pushes a page past 256M, the error tells you something changed. With an unlimited limit, the same leak just shows up later as a slow site and a mystery server bill.
The Bottom Line
The WordPress memory exhausted error is a two-part fix. First, get the site back up by raising WP_MEMORY_LIMIT to 256M in wp-config.php, and raise the server’s PHP memory limit if it’s capped lower. Then spend ten minutes with Query Monitor or a plugin test to find what’s actually using the memory. Skip the second part and the error isn’t fixed, it’s just postponed.
If you’d rather have someone handle it (or your site keeps hitting limits no matter what you try), take a look at recent projects and get in touch.
Frequently Asked Questions
Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above the “That’s all, stop editing” line. If the error persists, raise the server’s PHP memory_limit through your hosting panel or php.ini, or ask your host to raise it for you.
WordPress tries to set the memory limit to 40MB for single sites and 64MB for multisite on front-end requests, and 256MB for admin tasks through WP_MAX_MEMORY_LIMIT. The server’s PHP memory_limit can override these defaults if it is set higher.
WP_MEMORY_LIMIT cannot go above the server’s PHP memory_limit, so if the host caps PHP at 128M, requesting 256M in wp-config.php has no effect. The define also gets ignored if it is placed below the “stop editing” line in wp-config.php.
WooCommerce’s server recommendations call for a WordPress memory limit of 256 MB or greater. Large stores with many products, extensions, or a page builder like Elementor often need 512 MB.
Setting the PHP memory limit to -1 (unlimited) is not safe on a live site, because a single runaway request can consume all available server RAM and slow down or crash every other request. A fixed limit of 256M to 512M covers nearly all WordPress sites and still catches memory leaks early.

Leave a Reply