WordPress Memory Exhausted Error: How to Fix It

Last Updated: 23 Nov, 2026

The WordPress memory exhausted error means your site ran out of the PHP memory it is allowed to use. Fix it by adding define(‘WP_MEMORY_LIMIT’, ‘256M’); to wp-config.php above the line that says to stop editing, then find the heavy plugin or image that caused the spike so the error does not return.

What does the memory exhausted error mean?

If the error says “Memory Exhausted”, your site has run out of brain power.

In technical terms, PHP gives every request a fixed amount of memory. When a plugin, theme or large task needs more than that, PHP stops and WordPress shows a message such as “Allowed memory size of 41943040 bytes exhausted”. That number is the limit in bytes. Divide it by 1,048,576 and you get 40, which is 40 megabytes.

What causes it?

Cause Example
Heavy plugin A backup, page builder or SEO scanner running a big task
Large image processing Uploading a very large photo that WordPress must resize
Too many plugins at once Many plugins each loading code on every page
Low host limit A cheap plan with a small memory cap
Memory leak A buggy plugin that keeps asking for more

How to fix it: increase the WordPress memory limit

Add define(‘WP_MEMORY_LIMIT’, ‘256M’); inside wp-config.php, above the line that says “That’s all, stop editing!”.

Follow these steps:

  • Open File Manager and go to public_html.
  • Download a backup copy of wp-config.php.
  • Right-click wp-config.php and choose Edit.
  • Find the line that says “That’s all, stop editing! Happy publishing.”
  • Paste the memory line just above it and save.
  • Reload the page that showed the error.

WordPress documentation describes WP_MEMORY_LIMIT as the setting that controls the PHP memory limit for WordPress only, and lists a default of 40 MB for a single site. That is why a heavier site often hits the limit quickly.

If the error comes back: check the host limit

Your server has its own limit, and WordPress cannot ask for more than the host allows. If you raise WP_MEMORY_LIMIT and the error stays, open your hosting panel and look for a PHP settings area with a memory limit option, or ask support to raise it. Some low-cost plans cap memory.

You can also see the current limit inside WordPress under Tools, Site Health, Info, in the server section.

How much memory should you ask for?

Site type Starting point
Small blog or brochure site 128M
Business site with a page builder 256M
Online store or heavy plugins 256M or more, with host approval

These are rough starting points, not rules. Raise in steps, test each time, and stop when the error disappears.

Find the real culprit

Raising the limit treats the symptom. To fix the cause, work through these checks:

  • Note what you were doing when the error appeared, such as uploading an image or running a backup.
  • Turn on debug logging as described in the white screen article, then read debug.log for the plugin name.
  • Deactivate the named plugin and test.
  • Reduce image sizes before uploading.
  • Delete plugins you do not use.

A worked example (illustrative): importing a product catalogue

Imagine a store owner importing 800 products with images into a WooCommerce shop on a small hosting plan. Halfway through, the screen shows a memory exhausted message and the import stops. The owner raises WP_MEMORY_LIMIT to 256M, retries and the import completes. Later, the same error appears when a backup plugin runs. The cause this time is a backup of a now much larger site. The owner moves the backup to a quiet night hour and asks the host to raise the PHP limit. Two different tasks, two different fixes, one underlying cause: the site grew past its starting limits.

Warning signs your site is outgrowing its plan

If you keep raising the memory limit and errors return every few weeks, the problem is not a setting. Either a plugin is misbehaving or your site needs a bigger hosting plan. Check which plugins use the most resources and compare your traffic and content growth with the plan you bought.

Where to look if the error keeps returning

Keep a short log: the date, the task you were doing and the fix you applied. After two or three entries, a pattern usually shows up, such as the error appearing only during imports or backups. That pattern tells you whether to change a plugin, change a schedule or change your hosting plan.

Quick prevention checklist

  • Resize images before upload.
  • Keep plugins lean and updated.
  • Schedule heavy tasks, such as backups, for quiet hours.
  • Review plugins every three months.

Frequently Asked Questions

Is 256M too much memory for WordPress?

It is a common choice for sites with a page builder. Small sites may run fine on less, and your host may not allow more, so ask for what you need.

Will increasing memory make my site faster?

Not directly. It prevents crashes, but it does not make slow code faster. For speed, fix images, plugins and caching.

Can I fix this error without access to files?

Ask your host to raise the PHP memory limit, or look for a PHP configuration option in your hosting panel.

Why does the error only appear when I upload images?

WordPress needs memory to create resized copies of each image. A very large photo can exceed a low limit. Resize it before uploading.

Does deactivating a plugin free up memory?

Yes, because its code no longer loads on each page. That is why removing unused plugins helps.

Where do I see the exact error?

On the page itself or in the debug.log file if you have logging on. The message names the file that ran out of memory.