Fix WordPress Memory Exhausted Error in Minutes

What Does the WordPress Memory Exhausted Error Look Like?

laptop, wordpress, wordpress design, smartphone, work station, notebook, coffee, computer, website, mobile, business, ph
Photo by 27707 on Pixabay

You’ve probably seen it—a white screen where your website should be, or a message like “Allowed memory size of 41943040 bytes exhausted.” That’s the WordPress memory limit issue.

The error shows up in a few different ways. Visitors might see a blank page on the frontend. On the backend, you could be locked out of your admin dashboard entirely. Or you might see it when uploading media, installing a plugin, or saving a post.

Sometimes it’s partial—the admin loads but specific pages don’t, or certain widgets break. The exact wording varies, but the core issue is the same: WordPress has run out of allocated PHP memory.

Catching this early matters. Ignore it, and your site becomes unreliable for both you and your visitors. The good news is this is one of the most common WordPress errors and almost always fixable in minutes.

A blank white screen on a computer monitor showing a WordPress error

Why Does This Error Happen? Common Causes

There’s no single cause, but a handful of usual suspects. Identifying which one applies to you makes the fix faster.

  • Plugin conflicts. A poorly coded plugin or one that loads too much data at once can exhaust memory quickly. This is the most common cause after hitting the default limit.
  • Poorly coded themes. Some themes, especially multipurpose ones with lots of built-in features, consume more memory than they should. If the error started after a theme update, that’s a clue.
  • Large media files or image heavy pages. WordPress tries to process images when you upload them. Uploading several large files at once can hit the limit.
  • Default memory limit. Many hosts set the PHP memory limit to 32MB or 40MB. WordPress recommends at least 64MB, and most modern sites need more. That base limit is often the trigger.

This isn’t always a hosting problem. Some cheap shared hosts restrict memory, but a well-configured site on decent hosting should run fine with the right limit. The error often points to a specific plugin or theme issue that pushed you over the edge.

Before You Start: Backup Your Site

Before editing any files, make a fresh backup of your site. This is not optional if you want to work safely.

The quickest way is using a plugin like UpdraftPlus or Duplicator. UpdraftPlus lets you schedule automatic backups and store them remotely. Duplicator is better for a full site package you can restore easily. Both have free versions that work fine for this.

If your hosting provider offers automated backups (like SiteGround or WP Engine do), make sure the latest one is recent. Either way, a manual backup before editing critical files is cheap insurance. For those who work on multiple sites, having a reliable USB drive for backups on hand adds an extra layer of security. It takes two minutes and saves you from a potential headache if something goes wrong during the fix.

Method 1: Increase the WP Memory Limit via wp-config.php

This is the most reliable method and the one I use first in most cases.

You’ll need access to your site’s files. Use an FTP client like FileZilla or your hosting control panel’s file manager. Never edit files directly in the WordPress admin plugin editor—always use a proper code editor like VS Code or Sublime Text. Plain text editors can corrupt the file formatting.

Navigate to the root directory of your WordPress installation and open wp-config.php in your code editor.

Add this line of code just before the line that says /* That’s all, stop editing! Happy blogging. */:

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

This sets the memory limit to 256MB. For most sites, that’s plenty. If your host allows more and you have a complex site, you can go up to 512M, but 256M is a good starting point.

After you save the file, check your site. The error should be gone. If not, try increasing to 512M and test again.

One important note: some managed hosts (like WP Engine) don’t allow overriding memory limits in wp-config.php—you have to do it through their interface or contact support. If you’re on a host like that, skip this method and use Method 3.

computer, keyboard, letters, typing, code, laptop, electronics, gray computer, gray laptop, gray letter, gray code, gray
Photo by StockSnap on Pixabay

A code editor open on a laptop showing wp-config.php file with PHP code

Method 2: Increase Memory Limit via .htaccess (For Shared Hosting)

If the wp-config method doesn’t work or you’re on shared hosting where that file isn’t accessible, try .htaccess.

Open the .htaccess file in your WordPress root directory (same folder as wp-config.php). Add this line:

php_value memory_limit 256M

Place it anywhere in the file, but preferably after the # BEGIN WordPress lines to avoid conflicts with WordPress’s own rules.

This method works because some hosts allow PHP directives in .htaccess as a fallback. It’s not as universally reliable as the wp-config method, but worth trying if you’re stuck.

If neither method works, your host almost certainly restricts these settings at the server level. That’s fine—move to the next method.

Method 3: Ask Your Hosting Provider to Increase Memory

Some managed hosting providers, including WP Engine, Kinsta, and Flywheel, don’t let you change PHP memory limits via standard WordPress files. They do this for stability and security reasons. Instead, you need to contact their support team or use their custom dashboard.

When you reach out, ask them to increase the PHP memory limit to at least 256MB. Give them context—mention you’re seeing the “allowed memory size exhausted” error. Most managed hosts handle this quickly, often within minutes via live chat.

If you’re on budget shared hosting (like Bluehost or HostGator), you may need to upgrade your plan or move to a better host. Many cheap shared hosts cap memory at 128MB or 256MB regardless of what you set in code. If your site outgrows that, you’ll need to consider a VPS or managed WordPress host.

How to Identify the Culprit: Debugging Plugins and Themes

If increasing the memory limit fixed the error but you suspect one plugin or theme is using too much, this section is for you. The goal is to find what’s actually causing the problem so you can address it long-term.

Start by disabling all plugins. If the error disappears, re-enable them one by one, checking the site after each activation. The plugin that causes the error to reappear is your problem.

If disabling plugins doesn’t work, switch to a default WordPress theme like Twenty Twenty-Four. If the error stops, your theme is the issue.

Use a staging site if possible. Most hosts offer one-click staging. If not, use a maintenance mode plugin to prevent visitors from seeing a broken site while you troubleshoot.

For deeper diagnostics, install the Query Monitor plugin. It shows you how much memory each plugin and theme component uses. Helpful if the culprit isn’t obvious from simple disabling.

A common mistake is assuming the error is caused by a plugin that was recently updated. Sometimes the problem is a plugin that hasn’t been updated in months and has a conflict with a newer version of WordPress or another plugin. Check recent changes, but also check compatibility.

When to Use a Plugin Like WP Memory Optimizer (And When Not To)

There are plugins that claim to fix memory issues by editing wp-config.php for you. WP Memory Optimizer is the most well-known example. It’s useful if you’re uncomfortable editing files directly.

The tradeoff is that plugin-based fixes add another dependency to your site. You’re installing a plugin just to change one line of code. That’s not ideal for long-term maintenance.

For non-technical users who want a quick fix without touching code, a memory optimizer plugin works. But I’d recommend uninstalling it after it does its job, or at least keeping it as a temporary solution while you learn to edit wp-config.php yourself.

Beyond memory optimizers, there are plugins that genuinely help reduce memory usage through optimization. WP Rocket is a caching plugin that can significantly reduce server load. Asset CleanUp lets you disable unused CSS and JavaScript on specific pages, which lowers memory usage per request. These are worth considering for ongoing optimization, but they’re not alternatives to fixing the immediate error.

Common Mistakes to Avoid When Fixing This Error

Here are the pitfalls I see most often:

wordpress, blogging, blogger, editor, blog post, cms, blog, write, publish, publication, social media, wordpress, wordpr
Photo by pixelcreatures on Pixabay
  • Editing wp-config.php with a plain text editor. Use a proper code editor. Plain text editors can add invisible formatting characters that break the file.
  • Setting memory too high. If you set it to 1024M on a shared host, your server might crash or refuse the request entirely. Stick to 256M or 512M unless your host specifically supports higher limits.
  • Ignoring PHP version. Older PHP versions handle memory differently. Make sure your site runs on PHP 8.1 or 8.2 for best performance.
  • Skipping plugin updates. Outdated plugins are a common cause of memory leaks. If you have plugins that haven’t been updated in over a year, replace them first.
  • Not checking recent changes. If the error started after you installed a new plugin or activated a new theme, that’s your likely culprit. But sometimes it’s a gradual problem that builds up over weeks, so checking recent changes alone isn’t enough.

WordPress admin dashboard with a list of plugins deactivated for troubleshooting

What If the Error Persists? Next Steps and Hosting Upgrades

If you’ve tried all three memory increase methods and still see the error, you’re dealing with a deeper issue. Here’s what to check next:

  • Optimize your database. Large, unoptimized databases can consume more memory. Use a plugin like WP-Optimize to clean up post revisions, spam comments, and transients.
  • Reduce PHP processes. If your site has multiple cron jobs or external requests running simultaneously, they can exhaust memory. Check your cron event list in the database and disable unnecessary ones.
  • Consider a hosting upgrade. A $5 shared hosting plan has real limits. If your site gets decent traffic or runs complex functionality, a mid-tier managed WordPress host ($20–$40/month) usually solves persistent memory issues. Providers like SiteGround and Cloudways offer reliable options at that price point. Their support teams can also help diagnose what’s using memory.

Be realistic. A site with 50 plugins, heavy media files, and daily traffic on a budget host is going to hit limits. The solution isn’t just increasing memory—it’s reducing what’s consuming it or moving to infrastructure that can handle the load.

Final Checklist: Quick Fixes in Under 10 Minutes

If you’re in a hurry, here’s the fastest sequence to get your site back online:

  • Backup your site (2 minutes)
  • Increase memory via wp-config.php to 256M (2 minutes)
  • If that doesn’t work, try .htaccess method (1 minute)
  • If still down, disable all plugins and re-enable one by one (5 minutes)
  • If plugins aren’t the issue, switch to a default theme (2 minutes)
  • If still broken, contact your host (5 minutes)

That’s it. Most cases resolve at step 2 or 4. You’re usually back online before your morning coffee gets cold.

Prevent the Error from Returning: Long-Term Best Practices

Fixing the error once is good. Keeping it from coming back is better.

  • Monitor your site performance. Use GTmetrix or the free version of Query Monitor to check memory usage regularly. If a plugin starts creeping up, you’ll notice before it becomes a problem.
  • Keep plugins minimal. Every plugin adds some overhead. Audit your plugin list every few months. Delete anything you don’t actively use.
  • Use caching. A caching plugin like WP Rocket reduces server load significantly. That means less memory used per visit.
  • Schedule regular plugin reviews. Once a quarter, check for plugin updates, read changelogs, and test your staging site for compatibility.

No single action guarantees you’ll never see the error again. But consistent maintenance lowers the odds dramatically.

Conclusion

The WordPress memory exhausted error is one of the most common issues site owners face, but it’s also one of the simplest to fix. In most cases, adding one line of code to wp-config.php or contacting your host resolves it in minutes. The steps here cover the vast majority of scenarios.

Take a moment now to apply what you’ve learned—backup your site, increase your memory limit, and check which plugin or theme might be causing the trouble. You’ll be back to normal quickly.

If you prefer a hands-off approach or need ongoing support keeping your site running smoothly, our maintenance plans at Manage WP Websites handle all of this for you. No headaches, no troubleshooting—just a reliable site.

Similar Posts