Guide WordPress

How to increase the WordPress memory limit

Raise WP_MEMORY_LIMIT in wp-config.php first, then the server-wide PHP limit behind it if the error keeps coming back.

Updated 6 min read Beginner

An error reading "Allowed memory size of ... bytes exhausted" means PHP hit the ceiling on how much memory it was allowed to use for that request and stopped rather than continuing indefinitely. WordPress has two separate memory limits stacked on top of each other, and fixing this properly means understanding which one you are actually raising.

The two limits, and how they relate

LimitSet whereWhat it caps
WP_MEMORY_LIMITwp-config.phpWhat WordPress itself requests — this is the one WordPress-specific fatal errors usually refer to
PHP's memory_limitServer or account-wide PHP configurationThe hard ceiling for any PHP process on the account — WordPress cannot exceed this no matter what WP_MEMORY_LIMIT says

Raising WP_MEMORY_LIMIT above the server-wide PHP limit has no effect, because the server-wide value is the actual ceiling. Start with the WordPress setting, and only move to the server-wide one if the error persists.

Step 1: raise WP_MEMORY_LIMIT

  1. Open wp-config.php

    It sits in the root of your WordPress install. Connect over FTP or use the file manager in your control panel.

  2. Add this line above the "stop editing" comment

    Find the line reading /* That's all, stop editing! Happy publishing. */ and add your definition directly above it.

    define( 'WP_MEMORY_LIMIT', '256M' );
  3. Save and reload the site

    256M is a reasonable starting point for most sites; a busy site with several resource-heavy plugins may need more.

There is also a limit specifically for the admin area

WordPress applies a separate, usually higher, limit inside wp-admin, since the dashboard's own operations can be more memory-intensive than the public site. Set it with WP_MAX_MEMORY_LIMIT the same way, if the error only occurs while logged into the dashboard rather than on the front end.

Step 2: raise the server-wide PHP limit, if needed

If the error continues after raising WP_MEMORY_LIMIT, the server-wide PHP limit is likely lower and is capping things regardless of what WordPress asks for. This is controlled from your control panel rather than inside WordPress:

  • Open the PHP settings section of your control panel.
  • Find memory_limit in the list of PHP configuration values.
  • Raise it to match or exceed the value you set in WP_MEMORY_LIMIT — 256M or higher, depending on what the site needs.
  • Save. Unlike editing wp-config.php, this can take effect on the next request with no further action needed.

See increasing the PHP memory limit for more detail on where this setting lives if your control panel's layout differs from what is described here.

How to check which limit is actually being hit

The exact wording of the fatal error tells you which ceiling was reached — look at the number quoted in the message, and compare it against both settings. If the number matches your WP_MEMORY_LIMIT value, that is the one still too low. If it matches neither and is lower than both, the server-wide PHP configuration outside your control panel's own settings is capping things, in which case contact support, since that limit may need adjusting on the server side.

Do not just keep raising the number

A one-off memory error on an otherwise normal site is worth fixing by raising the limit and moving on. A site that keeps hitting new, higher limits every few months is telling you something else is wrong — usually a specific plugin using far more memory than it should, or simply more plugins active than the site's hosting plan comfortably supports.

Raising the limit treats the symptom, not the cause

If you find yourself doubling the memory limit repeatedly over time, use finding the plugin that is slowing your site to identify what is actually consuming the memory, rather than continuing to raise the ceiling indefinitely.

If raising it does not resolve the error

  • Check for a typo in wp-config.php. A missing semicolon or misplaced quote in the line you added can itself cause a fatal error, which looks similar but is a different problem entirely.
  • Confirm the file actually saved. If you are using a caching layer or a version control system alongside FTP, occasionally an edit does not persist the way you expect.
  • Ask your host to confirm the account's PHP memory ceiling if your control panel does not expose a memory_limit setting directly, since on some hosting configurations this is set at the server level rather than per account.

Once resolved, the change is permanent — there is nothing further to do unless you later install something that needs even more memory.

Why WordPress runs out of memory in the first place

PHP allocates memory for the duration of a single request and releases it when that request finishes, so a memory error is always about one page load using too much, not about the server accumulating memory over time. Plugins that load large libraries, process big images, generate PDFs, or handle bulk imports are the usual sources of a heavy single request. A default WordPress install with a handful of lightweight plugins rarely comes close to even a modest limit; the error shows up almost exclusively once a site has accumulated a number of more demanding plugins, or one particularly memory-hungry one.

This is also why the error can appear suddenly on a site that has run fine for months — installing or updating a single plugin is often all it takes to push a request over a limit that had comfortable headroom before.

If the site instead goes completely blank with no error text at all, rather than showing the memory message, see fixing the WordPress white screen of death — a memory exhaustion is one of its most common causes, and that guide covers how to turn on logging so the underlying error becomes visible instead of a blank page. Background on the file you are editing throughout this process is in what wp-config.php is and what is in it.

Related reading