Skip to content
Black Friday 50% off + 15,000 credits Ends Nov 30 Ends Nov 30 see the deal
Black Friday15,000 free credits + 50% offends Nov 30

WordPress Memory Limit: How to Check It and Increase It Safely

"Allowed memory size exhausted" means a page asked PHP for more memory than it's allowed. Raising the limit takes one line in wp-config.php, but only if your host lets WordPress change it, and a site that keeps needing more usually has a plugin worth a closer look. Here is how to check the limit, raise it, and find the cause.

In this article
  1. 01The short answer
  2. 02What the error means
  3. 031. Check your current limits
  4. 042. Raise WP_MEMORY_LIMIT in wp-config.php
  5. 053. When the number won't change: PHP's own limit
  6. 064. If 256 MB isn't enough, find the cause
  7. 07Locked out of wp-admin?
  8. 08Keep PHP up to date while you're there
  9. 09Where WPOS fits
Key takeaways
  • "Allowed memory size of … bytes exhausted" means a PHP request hit PHP's memory_limit.
  • See your limits in Tools → Site Health → Info, under Server and WordPress Constants.
  • WordPress asks for 40 MB (64 MB on Multisite) and 256 MB for admin tasks, but never lowers PHP's own limit.
  • To raise it, add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above "That's all, stop editing!".
  • If the value doesn't change, your host controls PHP's limit: use the hosting panel, .user.ini, or ask the host.
  • If 256 MB isn't enough, find the plugin or task using the memory instead of raising the limit again.

The short answer

A PHP request on your site ran out of the memory it’s allowed. To fix it:

  1. Check the limits in Tools → Site Health → Info, under Server and WordPress Constants.
  2. Raise WordPress’s limit with define( 'WP_MEMORY_LIMIT', '256M' ); in wp-config.php.
  3. If the number doesn’t change, raise PHP’s own memory_limit in your hosting panel or a .user.ini file, or ask your host.
  4. If 256 MB still isn’t enough, find the plugin or task that uses the memory instead of raising the limit again.

What the error means

PHP gives every request a memory budget, set by its memory_limit setting. When a request tries to go over it, PHP stops with a fatal error like this:

Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 20480 bytes)
in /var/www/html/wp-content/plugins/example-plugin/includes/import.php on line 214

The first number is the limit in bytes; the second is the piece of memory that didn’t fit. The common limits:

Bytes in the messageLimit
41,943,04040 MB, WordPress’s default on a single site
67,108,86464 MB, WordPress’s default on Multisite
134,217,728128 MB, PHP’s default
268,435,456256 MB, WordPress’s default for admin tasks

Visitors don’t see that line. WordPress shows “There has been a critical error on this website” instead and, when the error comes from a plugin or theme, emails the site admin a recovery link. The full message is in that email, in your host’s PHP error log, or in wp-content/debug.log once logging is on (step 4). If you only get a blank page, our guide to the white screen of death covers that case.

1. Check your current limits

Go to Tools → Site Health, open the Info tab and expand two sections:

  • Server → PHP memory limit: PHP’s limit for normal page loads. In wp-admin you may also see PHP memory limit (only for admin screens), the higher limit WordPress gives administrators there.
  • WordPress Constants → WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT: what WordPress asks for on normal pages and for heavier admin tasks.

While you’re on the Server section, note the PHP version as well; it matters further down. With WP-CLI you can print both limits in one line:

wp eval 'echo "WordPress: " . WP_MEMORY_LIMIT . ", PHP: " . ini_get( "memory_limit" ) . PHP_EOL;'

WP-CLI runs PHP’s command-line version, which can have settings of its own, so treat Site Health as the number that counts for your visitors.

2. Raise WP_MEMORY_LIMIT in wp-config.php

Open wp-config.php in your site’s root folder with your host’s file manager or SFTP, and add this line above /* That's all, stop editing! */:

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

WordPress’s wp-config.php documentation says the line “has to be put before wp-settings.php inclusion”, which is what that comment marks. Save, reload Site Health, and check that both WP_MEMORY_LIMIT and the PHP memory limit now show 256M.

How it works, from WordPress 7.1’s own code:

  • WordPress’s default is 40 MB on a single site and 64 MB on Multisite. If PHP already allows more, WordPress leaves PHP’s limit alone: it only ever raises the limit, never lowers it. A 128 MB server stays at 128 MB.
  • Heavy work gets more. For administrators in wp-admin, for image processing and, since WordPress 6.3, for WP-Cron, WordPress raises the limit to WP_MAX_MEMORY_LIMIT, 256 MB by default, or PHP’s own limit if that’s higher. If large image uploads fail with a memory error, that’s the one to raise, for example with define( 'WP_MAX_MEMORY_LIMIT', '512M' );.
  • It only works if PHP lets it. WordPress changes the limit with PHP’s ini_set(). If the host has fixed the value, WordPress can’t change it and uses whatever PHP allows.

How much? 256M is the usual answer: WooCommerce’s server requirements ask for a WordPress memory limit “of 256 MB or greater”. Going much higher rarely fixes anything, and the wp-config documentation warns that raising the limit can hide the root of the issue until it comes back.

3. When the number won't change: PHP's own limit

If Site Health still shows the old value, the host decides PHP’s memory_limit. Try these, in order:

  1. Your hosting panel. Most hosts have a PHP settings page where you pick memory_limit from a list. It’s the safest way, because the host knows how PHP runs on your plan.
  2. A .user.ini file in the site’s root folder, on hosts that run PHP through FastCGI or PHP-FPM:
    memory_limit = 256M
    PHP re-reads .user.ini every five minutes by default, so give it a few minutes before you check.
  3. .htaccess, only when PHP runs as an Apache module:
    php_value memory_limit 256M
    On an Apache server that runs PHP any other way, Apache doesn’t understand the line and the whole site answers with a 500 error, so remove it straight away if that happens. Nginx ignores .htaccess files altogether.
  4. Ask your host. If it set the value with php_admin_value, the PHP manual says nothing in .htaccess or ini_set() can override it. On PHP 8.5 a host can also set max_memory_limit, a ceiling: any higher value is capped to it, with a warning. Then the plan’s limit is the limit, and only the host can raise it.

4. If 256 MB isn't enough, find the cause

If a site still runs out of memory at 256 MB, something is using too much, and raising the limit again usually just moves the crash. To find it:

  • Read the file path in the error. It shows where PHP was when memory ran out, often inside wp-content/plugins/plugin-name/. That plugin is the first suspect, though it isn’t always the one using most of the memory.
  • Log the errors. These lines in wp-config.php write every error to wp-content/debug.log without showing it to visitors:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    Switch them off again when you’re done: the log grows quickly, and in wp-content it sits in a folder the web server can serve.
  • Look at the heavy jobs. Imports and exports, backups, very large images and big scheduled tasks are the usual memory users. Run the job again with one suspect plugin switched off, on a staging sandbox or a copy of the site, and see whether the error goes away.

Caching also cuts how often heavy work runs at all; our guide to speeding up WordPress covers it.

Locked out of wp-admin?

If the memory error hits wp-admin itself, you can still fix it from outside WordPress: edit wp-config.php through your host’s file manager or SFTP (step 2). When the crash comes from a plugin or theme, WordPress also emails the admin address a link to recovery mode, which pauses the faulty plugin so you can log in; our guide to the critical error explains it. That email needs your site’s mail to work, so if it never comes, see why WordPress isn’t sending emails.

Keep PHP up to date while you're there

Out-of-memory handling was at the centre of a critical PHP fix in October 2026. On 21 October PHP released 8.5.12, 8.4.27, 8.3.36 and 8.2.35 to fix two vulnerabilities that “can allow unauthenticated remote code execution”, one of them in how PHP handles running out of memory, and the PHP team asked all users to update immediately. The same releases made memory_limit a soft limit, with a separate hard ceiling set by a new memory_hard_limit_percent setting, according to the PHP manual.

Check Site Health → Info → Server → PHP version. If it’s older than those versions, ask your host to update PHP.

Where WPOS fits

WPOS can’t raise a limit your host has fixed; the hosting panel or the host does that. What it saves is the digging. WPOS puts an AI agent inside wp-admin on the sites you already run, on any host, and it checks its own work before it reports a change as done. Finding the cause becomes one request:

“Read this site’s PHP and WordPress memory limits and PHP version from Site Health, check the error log for memory errors, tell me which plugin they come from, and test switching it off on the staging sandbox first.”

WPOS is our product, so weigh this section accordingly; you can try it free for 30 days with 5,000 credits, a live site plus a staging sandbox, and no card.

Frequently Asked Questions

WordPress asks for 40 MB on a single site and 64 MB on Multisite (WP_MEMORY_LIMIT), and 256 MB for admin screens, image processing and WP-Cron (WP_MAX_MEMORY_LIMIT). If PHP's own limit is higher, such as PHP's default of 128 MB, WordPress keeps PHP's limit.

Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above the line "That's all, stop editing!", then check Tools → Site Health → Info. If the value doesn't change, raise memory_limit in your hosting panel, php.ini or .user.ini, or ask your host.

Either the line sits below "That's all, stop editing!" in wp-config.php, or your host has fixed PHP's memory_limit so WordPress can't raise it. On PHP 8.5 a host can also cap it with max_memory_limit. Then your hosting panel or your host has to raise it.

WP_MEMORY_LIMIT applies to normal page loads. WP_MAX_MEMORY_LIMIT is what WordPress raises the limit to for administrators in wp-admin, for image processing and for WP-Cron, 256 MB by default.

256 MB is the usual setting, and WooCommerce asks for 256 MB or more. If a site still runs out at 256 MB, look for the plugin or task that uses the memory rather than raising the limit again.

In PHP, -1 means no limit at all. Avoid it on a live site: the PHP manual describes the limit as what stops a badly written script from eating up all the memory on the server.

Black Fridayends Nov 30

Start free with 15,000 credits.

Three times the usual 5,000, no card needed. Then 50% off your site licences for 2 months with FRIDAY50.

Claim 15,000 credits