How to Fix WordPress Memory Exhausted Error Manually


Published: 1 Oct 2026


Quick answer: How to Fix WordPress Memory Exhausted Error

To fix the WordPress “Allowed memory size exhausted” error, add define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php file, just above the line that says /* That's all, stop editing! */. If the error persists, your hosting provider is enforcing a server-level cap that no file edit can override, and you’ll need to contact them directly to raise it.

fix WordPress memory exhausted error

I’ve opened a WordPress dashboard to a blank white screen more times than I’d like to admit, and the memory exhausted error is one of the most common reasons behind it. It usually shows up at the worst moment,  mid-import, right after updating a plugin, or while uploading a batch of images, and it looks alarming because the message is full of byte counts and file paths that mean nothing to most site owners at first glance.

 It isn’t actually complicated once you know what you’re looking at, and this guide walks through exactly how to read it, fix it, and find out which plugin or theme caused it in the first place.

Key takeaways:

  • What it means: a PHP process on your site tried to use more memory than your server currently allows.
  • The quick fix: raising the memory limit in wp-config.php  usually solves it in under five minutes.
  • The real fix: if raising the limit doesn’t work, your host is enforcing a hard cap, and no file edit on your end can override it; you’ll need to contact them directly.

Understanding Memory Exhausted Error

Before fixing anything, it helps to actually understand what you’re looking at. Most people’s first instinct when this error shows up is to panic and start deactivating things at random, but the error itself is more informative than it looks, and reading it properly can save you a lot of guesswork later. 

This section covers two things: how to recognize that you’re dealing with a memory issue in the first place, and how to read the actual error message so it tells you something useful instead of just looking like a wall of numbers. 

Signs You’re Hitting the Memory Limit

You’re likely dealing with a memory limit issue, not some other kind of WordPress error, if you notice:

  • A completely white screen with no other symptoms,  no error text, no broken layout, just blank.
  • The literal text “Allowed memory size of X bytes exhausted” appearing somewhere on the page or in your error logs.
  • The error only happens during specific tasks,  importing content, running a plugin or theme update, uploading media, or using the block editor,  rather than on every page of your site.

Decoding the Error Message

A typical memory exhausted error looks like this:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8192 bytes) in /home/yoursite/public_html/wp-content/plugins/example-plugin/functions.php on line 87

Here’s what each piece actually means:

  • “Allowed memory size of 134217728 bytes” is your current PHP memory limit, in bytes. Divide by 1,048,576 to convert to megabytes (134217728 ÷ 1,048,576 = 128MB in this example).
  • “tried to allocate 20480 bytes” is the small extra chunk of memory that pushed the process over the limit. This number is usually tiny and isn’t the real issue; it’s just the straw that broke the camel’s back.
  • The file path  /wp-content/plugins/some-plugin/file.php is the most useful part of the entire message.  If that path points into a specific plugin’s folder, you already know your prime suspect before doing any further testing. Keep this in mind; it comes back in the diagnosing section below.

How to Fix the WordPress Memory Exhausted Error: Step by Step

Once you know you’re dealing with a memory issue, fixing it follows a clear order; try the easiest method first, then work down the list only if it doesn’t resolve things. Here’s exactly how, step by step.

Step 1: Check Your Current Limit First

Before changing anything, confirm what your site is actually working with. Go to Tools → Site Health → Info, expand the Server section, and look for PHP memory limit. Most fresh WordPress installs default to 64MB or 128MB, which is often too low for a site running several plugins or a page builder.

Step 2: Edit wp-config.php (Easiest)

This is the fix that resolves the error for most sites, and it’s the one I reach for first every time.

  1. Connect to your site through FTP or your host’s File Manager.
  2. Locate wp-config.php in your WordPress root directory.
  3. Open it and find the line that reads /* That's all, stop editing! */.
  4. Paste this code just above that line:
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');

These two lines look alike, but they do different jobs: WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT are not the same setting. WP_MEMORY_LIMIT governs memory for your site’s front end,  what visitors see. WP_MAX_MEMORY_LIMIT governs memory for admin-side tasks specifically,  plugin updates, media imports, and the block editor, which tend to be more memory-hungry than a normal page load.

Setting only the first one can leave you still hitting the error every time you try to update a plugin, even though your actual site loads fine. Set both.

  1. Save the file and reload your site

This constant is documented directly in WordPress’s own developer reference, which confirms the same default behaviour described above.

Step 3: Choose the Right Number for Your Site

There is no single right number. The best limit depends on what your site does: 

  • A basic blog or brochure site: 256M is usually plenty.
  • A WooCommerce store, especially one running bulk product imports or exports: 512M is a safer starting point; imports are one of the most memory-intensive tasks WordPress performs.
  • A site built heavily with a page builder like Elementor or Divi: these add their own processing overhead on top of WordPress core, so 512M tends to prevent recurring issues rather than just patching the current one.

Set the number for how your site actually gets used, not the first figure you find in a forum post.

Step 4: Edit php.ini (Most Reliable, If You Have Server Access)

If editing wp-config.php didn’t resolve the error, your server itself may be enforcing a lower ceiling that overrides WordPress’s request. Editing php.ini directly is the most reliable fix when you have access to do it, because it changes the limit at the server level rather than asking WordPress to request more than it’s allowed.

  1. Locate php.ini in your site’s root directory (or create a blank file named .user.ini if php.ini doesn’t exist and your host supports that format instead).
  2. Add or edit this line:

memory_limit = 256M

memory_limit = 256M
  1. Save the file. Some hosts require a short wait or a server restart for the change to take effect.

If you can’t find or create this file, your hosting plan likely doesn’t give you direct server access; see Step 6 below.

Step 5: Edit .htaccess

The .htaccess method works similarly to editing php.ini, but it has one catch. It only works on Apache servers. If your site runs on Nginx or LiteSpeed, common on many managed hosting setups, .htaccess directives are silently ignored. 

You can add the line, save the file, and nothing will happen, with no error to tell you why. If you’re not sure which server software your host uses, check their documentation or ask support before spending time here

.

If you are on Apache:

  1. Locate .htaccess in your WordPress root directory.
  2. Insert this line after the # END WordPress block:
php_value memory_limit 256M
  1. Save and reload your site. If you see a “500 Internal Server Error” immediately after saving, your host doesn’t allow this directive; remove the line and move to Step 6.

Step 6: Still Not Working? Check Your Hosting Type First

If none of the above fixed it, the cause is very likely your hosting environment itself, not anything in your WordPress files. This step matters more than it looks:

  • Shared hosting or VPS/dedicated servers: you typically do have the access needed for the methods above, assuming your host doesn’t impose an account-level hard cap.
  • Managed WordPress hosting (Kinsta, WP Engine, and similar): these hosts frequently block direct php.ini and .htaccess memory overrides entirely, by design, as part of how they manage server resources across all their customers. If you’re on one of these platforms, Steps 4 and 5 may simply never work, no matter how correctly you follow them, and that’s not a mistake on your part.

If you’ve confirmed you’re on a managed host with these restrictions, or if you’ve genuinely outgrown your current plan’s limits, upgrading your hosting plan is the real fix, not another workaround. Continually pushing a site that needs more resources onto a plan that can’t provide them usually means this error keeps coming back in different forms.

Step 7: Verify the Fix Actually Took Effect

Don’t just reload the page and assume it worked; caching can make a page look fine even when the underlying memory limit never actually changed. Go back to Tools → Site Health → Info and confirm the PHP memory limit value shown now matches what you set. If it still shows the old number, your change didn’t take effect at the server level, which usually means you’re dealing with the hosting-cap situation in Step 6.

Diagnosing Which Plugin or Theme Is the Culprit

Raising the memory limit fixes the immediate error, but it doesn’t address why your site needed more memory in the first place. If the error keeps coming back even at 512M, something specific is consuming more than it should, and it’s worth finding out what.

Start with these two questions:

  • Did the error appear right after a plugin update or new install? If so, that’s almost certainly your starting point; a new or updated plugin is the most common trigger for a sudden memory spike on a site that was running fine before.
  • Does it happen on every page, or only during specific tasks (import, editor, checkout)? An error isolated to one specific task usually points to whatever plugin handles that task specifically, rather than something site-wide.

From there:

Read the file path in your error message first. Going back to the error breakdown earlier in this guide,  if the file path in your error text points into /wp-content/plugins/some-plugin-name/, you likely already have your answer without deactivating a single thing.

Deactivate-and-reactivate method. If the file path doesn’t make the culprit obvious, go to Plugins → Installed Plugins, deactivate everything, confirm the error is gone, then reactivate plugins one at a time, checking your site after each one. 

The moment the error returns, you’ve found it.

WP-CLI method for agencies. If you manage multiple WordPress sites, scripting this process saves real time over clicking through the dashboard on each one:

wp plugin deactivate --all

wp plugin activate <plugin-name>

Reactivate one at a time and reproduce the task that triggered the error after each command.

Here is a safer way to find the problem plugin. Install Health Check & Troubleshooting and test from your own account. Visitors won’t notice anything, because the plugin turns things off only for you. Our guide on reducing WordPress plugin conflicts covers the full process. It works for memory errors too. 

Contact Your Host  With the Right Script

If you’ve confirmed your site is hitting a server-level hard cap, a quick support message to your host is usually faster than any further troubleshooting on your end.

 Here’s a script you can copy and send as-is:

“Hello, my WordPress site keeps showing this error: ‘Fatal error: Allowed memory size exhausted.’ I need help fixing it. My current PHP memory_limit is set to [your current limit from Site Health]. Could you please increase the PHP memory limit for my account to 256M or 512M?

Most hosts can make this change from their end in minutes, even on plans where you don’t have direct file access to adjust it yourself.

Prevent This From Happening Again

A higher memory limit stops the immediate error, but a few habits reduce how often you hit the ceiling in the first place:

  • Deactivate and remove unused plugins. Every active plugin adds to your site’s baseline memory usage, whether you’re actively using its features or not.
  • Optimize your images. Large, unoptimized media files are one of the more common silent memory hogs, especially during uploads and imports.
  • Use a caching plugin. Caching reduces how much PHP processing happens on each page load, which lowers overall memory demand across the board.

Conclusion

The memory exhausted error looks intimidating the first time you see it, but it almost always comes down to one of three things: a limit that needs raising, a specific plugin that needs finding, or a hosting-level cap that only your host can lift.

Start with wp-config.php, work through the remaining methods only if that doesn’t resolve it, and don’t skip the diagnosing step; fixing the symptom without finding the cause usually means you’ll be back here again before long.

And if you’ve genuinely hit a wall your host is enforcing, the fastest path forward isn’t another file edit; it’s the support script above.

Still troubleshooting? These related guides cover other common WordPress issues: Plugin Conflicts After Update, Dashboard Widgets Missing, and 404 Error After Changing Permalinks.

Frequently Asked Questions

What causes the WordPress memory exhausted error?

A PHP process on your site asked for more memory than your server allows. Heavy plugins, large imports and big image uploads are common triggers. The message shows the limit and the file that hit it. Read that file path first.

How much memory does WordPress need?

A simple blog usually runs well on 256MB. A WooCommerce store or a page builder site does better with 512MB. Bulk imports and exports use the most memory. Check Tools → Site Health → Info to see your current limit.

Is it safe to increase the PHP memory limit?

Yes, within the limit your host allows. Raising it does not harm your site. It only lets PHP use more of the server’s memory when it needs to. Very high values on shared hosting may be ignored or capped.

Why does the error come back after I raise the limit?

Something on your site is using too much memory. A heavy plugin or a bulk task is the usual cause. Use the diagnosing steps above to find it. Raising the limit again only hides the problem for a while.

Can a plugin cause the memory exhausted error?

Yes. One heavy plugin can use more memory than the rest of your site combined. Check the file path in your error message first, because it often names the plugin. If it doesn’t, switch plugins off one at a time and test your site after each one. 

How do I fix the error if I can’t open my dashboard?

Use FTP or your host’s File Manager. Edit wp-config.php and add the memory limit lines from Step 2. You can also rename the plugins folder to switch off all plugins at once. Rename it back after you find the cause.

How do I solve a PHP fatal error in WordPress?

Most PHP fatal errors point to a specific file and line number in the error message itself; read that first, since it usually names the plugin or theme file responsible. From there, deactivating the plugin or switching to a default theme temporarily will confirm the source.


Haj Bibi Avatar
Haj Bibi

Hi, I'm Haj Bibi. I specialize in WordPress and SEO, helping websites perform better, rank higher, and reach the right audience. I share practical tips and strategies to make managing and optimizing websites easier for everyone. Learn more about my experience and approach on our About Us page.


Please Write Your Comments
Comments (0)
Leave your comment.
Write a comment
INSTRUCTIONS:
  • Be Respectful
  • Stay Relevant
  • Stay Positive
  • True Feedback
  • Encourage Discussion
  • Avoid Spamming
  • No Fake News
  • Don't Copy-Paste
  • No Personal Attacks
`