---
title: "How to fix \"Allowed memory size exhausted\" in WordPress"
url: https://wpministry.co/errors/allowed-memory-size-exhausted/
description: "PHP stopped a page that needed more memory than it is allowed. Raising WordPress's memory limit in wp-config.php clears it on most hosts."
lang: en-US
---

Skip to content

# How to fix "Allowed memory size exhausted" in WordPress

A page needed more memory than PHP is allowed to use, so PHP stopped it. Raising WordPress's memory limit in wp-config.php clears it on most hosts. The error message itself names the file that asked for too much, which tells you what to look at if it comes back.

By

WP Ministry

Published

October 6, 2026

Tested on

WordPress 7.1.4, PHP 8.3.36

## In short

- The limit is a safety setting, not a fault in your site. One page asked for more than it allows.
- Adding one line to wp-config.php raises the limit on most hosts.
- If the line changes nothing, your host sets a ceiling that only they can lift.
- The message names a file. If it is inside a plugin's folder, that plugin is what is using the memory.

PHP, the language WordPress is written in, gives each page a fixed amount of memory to work with. When a page asks for more, PHP stops it and reports "Allowed memory size of … bytes exhausted". WordPress then shows visitors "There has been a critical error on this website" in its place.

The number in the message is the limit in bytes: 134217728 is 128 MB, and 268435456 is 256 MB.

## Where it goes wrong

A page request passes through each of these in turn. This one comes from **PHP, the language WordPress runs on**.

1. Browser
2. DNS
3. HTTPS
4. CDN or firewall
5. Web server
6. PHP (this error comes from here)
7. WordPress
8. Database and files

## What causes it

- ### The memory limit is lower than the site now needs
  Common
  Sites grow. A limit that suited a new site can be too small once it has a page builder, a shop and a dozen plugins.
  Fix: Raise WordPress's memory limit
- ### One plugin or theme is using far more than the rest
  Common
  A plugin that loads a whole file into memory, or that has a fault, can use up any limit however high it is set.
  Fix: Find what is using the memory
- ### The host caps memory below what you set
  Sometimes
  On some hosting plans the limit in the server's own settings cannot be raised from inside WordPress.
  Fix: Ask the host to raise PHP's own limit

## How to fix it

### Raise WordPress's memory limit

- Easy
- Back up first
- About 5 minutes
- Steps tested on WordPress 7.1.4
1. #### Step 1: Open wp-config.php
   It is in the folder WordPress is installed in, beside the `wp-content` folder.
2. #### Step 2: Add the line above "That's all, stop editing"
   Anything added below that line is read too late to count.
   wp-config.php Copy

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

3. #### Step 3: Save the file and reload the page that failed
   If it loads, the limit was the cause. If nothing changes straight away, wait a few seconds and reload: PHP can go on using its stored copy of the file for a moment after you save.

WordPress can only raise the limit, never lower it, and only as far as your host allows. If the page still fails with the same number in the message, the host's ceiling is in the way.

**To undo it:** Remove the line from wp-config.php.

### Find what is using the memory

- Takes care
- Low risk
- About 15 minutes
- Steps tested on WordPress 7.1.4

The error message ends with the path of the file that asked for the memory. WordPress hides that from visitors, but will write it to a log if you ask.

1. #### Step 1: Turn the debug log on
   In `wp-config.php`, find the line `define( 'WP_DEBUG', false );` and replace it with these three. If you have WP-CLI, the commands below do the same.
   wp-config.php Copy

   ```
   define( 'WP_DEBUG', true );
   define( 'WP_DEBUG_LOG', true );
   define( 'WP_DEBUG_DISPLAY', false );
   ```

2. #### Step 2: Load the page that fails
   Once is enough.
3. #### Step 3: Read the log
   Open `wp-content/debug.log` and find the line with "Allowed memory size". The path at the end of it shows where the memory ran out. A path through `wp-content/plugins/` followed by a plugin's folder name points at that plugin.
4. #### Step 4: Turn the debug log off again
   Put the line back to `define( 'WP_DEBUG', false );`. The log can hold details you do not want left on a public server, so delete `debug.log` when you have read it.

bash

```
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_DEBUG_DISPLAY false --raw
```

When you have what you need:

bash

```
wp config set WP_DEBUG false --raw
wp config set WP_DEBUG_LOG false --raw
```

Switch that plugin off and load the page again. If it loads, you have found the cause: update the plugin, replace it, or tell its author.

### Ask the host to raise PHP's own limit

- Easy
- No risk
- About 15 minutes

If the line in `wp-config.php` makes no difference, the limit is set in the server's PHP settings, above WordPress.

1. #### Step 1: Look for a PHP settings page in your hosting panel
   Many hosts let you change `memory_limit` yourself, under a name such as "PHP settings" or "PHP options".
2. #### Step 2: If there is none, ask support
   Ask them to set PHP's `memory_limit` to 256M for your site, and whether your plan allows it.

## When to get help

If the limit is at 256M and the error is still there, raising it further hides the problem instead of solving it. Something is using memory it should not, and finding it means reading the log and testing with plugins switched off.

## Common questions

How much memory does WordPress need?

WordPress asks for 40 MB by default and allows itself up to 256 MB in the dashboard. A site with a page builder or a shop commonly needs 256 MB for visitors as well.

Is a higher limit always better?

No. The limit is there so that one runaway page cannot take the whole server's memory. Set it to what the site needs and find out why if it needs more.

Why does it only happen sometimes?

Different pages do different work. Uploading a large image, running a backup or importing products needs far more memory than showing a post.

## More on this subject

- WordPress errors and troubleshooting: https://wpministry.co/topics/wordpress-troubleshooting/
- Guide How to update the PHP version of a WordPress site: https://wpministry.co/blog/update-php-version-wordpress/
- Guide WordPress uptime monitoring: what a check sees and what it misses: https://wpministry.co/blog/wordpress-uptime-monitoring/
- Glossary term .htaccess: https://wpministry.co/glossary/htaccess/
- Guide Locked out of WordPress admin: find which lockout you have and get back in: https://wpministry.co/blog/locked-out-of-wordpress-admin/
- Glossary term Must-use plugin (mu-plugin): https://wpministry.co/glossary/must-use-plugin/
- Glossary term Permalink: https://wpministry.co/glossary/permalink/

## Would you rather we fixed it?

Quick Fix is $49. One issue, one site, up to about an hour. No fix, no fee. 30-day warranty.

More about this work: One-time WordPress fix (https://wpministry.co/services/one-time-fix/)

May we measure how this site is used?

A yes notes the pages of this visit and loads Google Analytics. A no keeps and loads nothing. See the cookies page (https://wpministry.co/legal/cookies/).

If you say yes, we note the pages you look at during this visit and load Google Analytics. If you say no, nothing is kept and nothing is loaded. The site works the same either way. The cookies page (https://wpministry.co/legal/cookies/) has the details.

## Structured data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "@id": "https://wpministry.co/#organization",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "logo": "https://wpministry.co/brand/logo.png",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "1309 Coffeen Ave STE 1200",
        "addressLocality": "Sheridan",
        "addressRegion": "WY",
        "postalCode": "82801",
        "addressCountry": "US"
      },
      "sameAs": [
        "https://www.linkedin.com/company/wp-ministry/",
        "https://x.com/wpministryco",
        "https://www.instagram.com/wpministryco/",
        "https://www.facebook.com/wpministryco",
        "https://www.tiktok.com/@wpministryco",
        "https://www.pinterest.com/wpministryco/",
        "https://www.youtube.com/channel/UCOZRuAukk5QSTRPG6BaHl3Q"
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://wpministry.co/#website",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      }
    },
    {
      "@type": "TechArticle",
      "@id": "https://wpministry.co/errors/allowed-memory-size-exhausted/#article",
      "headline": "How to fix \"Allowed memory size exhausted\" in WordPress",
      "description": "PHP stopped a page that needed more memory than it is allowed. Raising WordPress's memory limit in wp-config.php clears it on most hosts.",
      "url": "https://wpministry.co/errors/allowed-memory-size-exhausted/",
      "mainEntityOfPage": "https://wpministry.co/errors/allowed-memory-size-exhausted/",
      "inLanguage": "en-US",
      "image": "https://wpministry.co/og/errors/allowed-memory-size-exhausted.png",
      "author": {
        "@id": "https://wpministry.co/#organization"
      },
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      },
      "datePublished": "2026-10-06T00:00:00.000Z",
      "dateModified": "2026-10-06T00:00:00.000Z"
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://wpministry.co/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Error fixes",
          "item": "https://wpministry.co/errors/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "How to fix \"Allowed memory size exhausted\" in WordPress"
        }
      ]
    }
  ]
}
```