Step-by-step fixes for Wi-Fi, printers, laptops and the apps you rely onResearch-backed guides to cookware, flavor, and everyday kitchen gear

WordPress Memory Exhausted Error Fix: 6 Methods 2026

If your WordPress site suddenly shows “Allowed memory size exhausted,” “Fatal error: Out of memory,” or the dreaded “There has been a critical error on this website” message, you have hit your PHP memory limit. In this guide, I will walk you through exactly how to fix the WordPress memory exhausted error using six different methods, from a one-line edit in wp-config.php to changes you can make straight from cPanel with no coding required. I will also show you how to verify the new limit, prevent the error from returning, and what to do when your host refuses to let you raise it.

By the end, you will know which file to edit, what value to use for your site type, and how to confirm the fix actually took effect. I have used every method below on real client sites and my own projects over the past several years, so the instructions are battle-tested.

What Is the WordPress Memory Exhausted Error?

The WordPress memory exhausted error is a PHP fatal error that appears when a script on your site tries to use more RAM than PHP is allowed to allocate. PHP, the language WordPress runs on, has a hard cap called the PHP memory limit. When a request – uploading media, running a plugin, generating a page – needs more memory than that cap allows, PHP kills the script and displays the error.

The classic message looks like one of these:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 67108864 bytes) in /home/yourname/public_html/wp-includes/plugin.php on line 1567

or simply:

Allowed memory size of 268435456 bytes exhausted

Since WordPress 5.2, most users never see this message directly. Instead, the site displays a generic screen that reads “There has been a critical error on this website.” WordPress also sends an email to the admin address with a recovery mode link and the underlying technical details. That email is the fastest way to confirm you are dealing with a memory issue rather than a plugin or theme conflict.

The fix itself is almost always the same: raise the PHP memory limit so the script has room to run. WordPress gives you a separate constant called WP_MEMORY_LIMIT for this, and your hosting control panel lets you adjust the server-side memory_limit setting as well.

Why You May Only See “There Has Been a Critical Error on This Website”

WordPress 5.2 introduced a feature called Fatal Error Recovery Mode. Instead of showing raw PHP errors to visitors (which can leak sensitive file paths and look unprofessional), WordPress hides the technical message and shows a clean screen. From your visitor’s perspective, the site simply looks broken.

To find out what is really happening, do one of the following:

  1. Check the admin email inbox for a message titled “Your Site is Experiencing a Technical Issue.” It contains a recovery mode link and a stack trace showing the exact file that ran out of memory.
  2. Enable WP_DEBUG temporarily by editing wp-config.php and setting define('WP_DEBUG', true); along with define('WP_DEBUG_LOG', true);. WordPress will then log errors to /wp-content/debug.log, which you can read over SFTP or File Manager.
  3. Open Tools → Site Health in your WordPress dashboard. The Info tab shows your current PHP memory limit and a breakdown of which limits WordPress is using.

Once you confirm the cause is the memory limit, proceed to the backup step below before editing any files.

Before You Begin: Back Up Your Site and Locate the Right Files

You will be editing core configuration files. Take a full backup first. I have seen small typos break sites for hours; a 60-second backup saves you.

  • Use your host’s backup tool. Most managed WordPress hosts (Kinsta, WP Engine, SiteGround, Cloudways) and cPanel both have a one-click “Backup” or “Snapshot” button. Run it before you touch anything.
  • Use a plugin if your host does not offer backups. UpdraftPlus and BlogVault both work, but only install them from a clean dashboard – if the site is already down, use the host’s backup instead.
  • Confirm access to your site files. You can use the cPanel File Manager, an SFTP client like FileZilla, or (on managed hosts) the host’s own file browser. The files you need – wp-config.php, .htaccess, and php.ini – live in your WordPress root directory, the same folder that contains the wp-admin and wp-includes folders. On most shared hosts this is public_html.

Warning: Never edit functions.php in your theme to change the memory limit. Forum threads still recommend this, but it gets overwritten every time your theme updates, and it disappears entirely if you switch themes. Use wp-config.php instead.

Before raising the limit, pick the right target value. Most shared hosts cap PHP at 128M, 256M, or 512M, and many explicitly forbid going higher regardless of what you set. Use this table as your starting point.

Site Type Recommended Memory Limit Notes
Small blog or personal site 128M Sufficient for a handful of plugins and modest traffic.
Business or marketing site 256M Comfortable room for page builders and contact-form plugins.
WooCommerce store 512M Cart, checkout, and product imports need extra memory.
LMS, membership, or multi-vendor site 512M to 1024M Heavy queries during checkout and lesson delivery.
Large multisite network 512M+ Use WP_MAX_MEMORY_LIMIT to give wp-admin extra room.

Setting 1024M on a small site rarely helps and can mask a plugin-level memory leak. If the error keeps coming back at very high values, the cause is almost certainly a buggy plugin rather than a capacity issue.

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

The fastest way to fix the WordPress memory exhausted error is to add a single line to wp-config.php. This is the method I try first on every site, and it works on the vast majority of hosts.

Step 1. Open your site root using File Manager or SFTP and locate wp-config.php. It sits in the same directory as wp-admin and wp-includes.

Step 2. Open the file in the editor and find the line that reads /* That's all, stop editing! Happy publishing. */ (or the older “Happy blogging” variant).

Step 3. Immediately above that line, paste the following:

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

Step 4. Save the file and refresh your site. For larger sites or admin-only errors, also add this line directly below it:

define('WP_MAX_MEMORY_LIMIT', '512M');

WP_MEMORY_LIMIT controls the memory available to your site’s frontend. WP_MAX_MEMORY_LIMIT controls memory for the WordPress admin area (wp-admin), which is where heavy operations like plugin installs, theme customizer, and WooCommerce reports run. Most users only need the frontend value, but admin-area memory errors disappear the moment you set WP_MAX_MEMORY_LIMIT.

Use straight single quotes inside define(). Curly quotes pasted from a word processor will break the file and cause a parse error. Use the correct case (WP_MEMORY_LIMIT, not wp_memory_limit) and end the line with a semicolon.

Method 2: Increase the Memory Limit in .htaccess

If your host runs Apache with mod_php, you can also set the memory limit from .htaccess. This file lives in your site root, alongside wp-config.php.

Step 1. Open .htaccess in your editor. If you do not see it, enable “Show hidden files” in File Manager, since .htaccess starts with a dot.

Step 2. Add the following line anywhere in the file:

php_value memory_limit 256M

Step 3. Save the file. Reload your site to confirm the change took effect.

Warning: This method only works on Apache with mod_php. If your host uses NGINX or PHP-FPM (common on Cloudways, RunCloud, GridPane, Kinsta, and WP Engine), editing .htaccess with php_value memory_limit will throw a 500 Internal Server Error. Use Method 3 or Method 5 instead if you see that.

Method 3: Increase the Memory Limit in php.ini

The php.ini file is the server’s main PHP configuration file. Raising the limit here applies to every PHP process on the server (or every process in that PHP version), so this is the strongest lever you have short of asking your host.

Step 1. Look for a file named php.ini in your site root. Some shared hosts hide it or do not create one by default. If it does not exist, create a blank file with that exact name.

Step 2. Add (or update) this line in php.ini:

memory_limit = 256M

Step 3. Save and, if your host requires it, restart PHP. On most cPanel hosts the change applies within seconds. On VPS and dedicated servers you may need to restart Apache, NGINX, or the PHP-FPM service.

Step 4. If you have multiple PHP versions installed (common on cPanel with MultiPHP), make sure you are editing the php.ini for the version your site actually uses. The version selector in cPanel shows which one is active for your domain.

Method 4: Increase the Memory Limit from cPanel, hPanel, or Plesk (No Code)

For non-technical site owners, the easiest path is the hosting control panel. You never touch a config file, and the change applies instantly.

On cPanel:

  1. Log in to cPanel and open MultiPHP INI Editor under the Software section.
  2. Select your domain from the dropdown at the top.
  3. Scroll to memory_limit and change the value (for example, to 256M or 512M).
  4. Click Apply or Save.

On hPanel (Hostinger):

  1. Open hPanel and go to Advanced → PHP Configuration.
  2. Switch to PHP Options and find memory_limit.
  3. Raise the value and save.

On Plesk:

  1. Open your domain and click PHP Settings.
  2. Find memory_limit in the Performance section.
  3. Enter the new value and apply.

This is the method I recommend for users who have never edited a config file before. Most shared hosts expose this UI on purpose because it prevents typos that bring a site down.

Method 5: Increase the Memory Limit via .user.ini (PHP-FPM / NGINX Hosts)

If your host runs PHP-FPM (NGINX, Cloudways, RunCloud, GridPane, and most modern managed hosts), the .htaccess approach will fail with a 500 error. Instead, use a file called .user.ini, which PHP-FPM reads automatically from each site’s document root.

Step 1. In your site root, look for a file named .user.ini. If it does not exist, create one.

Step 2. Add this line:

memory_limit = 256M

Step 3. Save the file. PHP-FPM reads .user.ini every few minutes (the user_ini.cache_ttl setting, usually 300 seconds), so wait a few minutes before testing.

Some hosts (notably Cloudways) require you to raise the memory_limit both in the server panel and in .user.ini for it to apply to wp-admin. If the frontend works but the admin still throws the memory error, the panel is the higher authority – update both.

Method 6: Contact Your Hosting Provider

If none of the above methods change the active limit, your host is enforcing a server-side cap. This is the most common complaint I see in WPBeginner comments and the r/Wordpress subreddit. Many shared hosts (GoDaddy shared, HostGator shared, several Czech and EU providers) hard-cap PHP memory at the plan level and ignore user edits.

When you open a support ticket, include:

  • Your current plan name
  • The exact error message you see, including the byte count (for example, Allowed memory size of 134217728 bytes exhausted)
  • The methods you have already tried
  • A request to raise PHP memory_limit to at least 256M (or 512M for WooCommerce)

If the host refuses, your options are to upgrade to a higher plan on the same provider or to move to managed WordPress hosting (Kinsta, WP Engine, Cloudways) where higher limits are standard.

How to Check Your Current WordPress Memory Limit

After any of the edits above, verify that the new limit is actually active. Many users change the value, see no difference, and assume the fix failed when in fact the host is still capping them.

Option 1: Site Health (no code required)

  1. In your WordPress dashboard, go to Tools → Site Health.
  2. Click the Info tab.
  3. Expand the Server and WordPress Constants sections.
  4. Look for PHP memory limit, WP_MEMORY_LIMIT, and WP_MAX_MEMORY_LIMIT. Each will show its current value.

Option 2: WP-CLI (for SSH users)

Connect to your server over SSH and run:

wp eval 'echo ini_get("memory_limit");'

The number returned is the PHP memory limit your WordPress site is actually using, in shorthand format (256M, 512M, and so on).

Option 3: phpinfo()

Create a temporary file called phpinfo.php in your site root containing <?php phpinfo(); ?>, open it in your browser, then delete it immediately after reading the memory_limit row. Leaving phpinfo() accessible is a security risk.

Why Your wp-config Edit Sometimes Does Not Work (Host Overrides)

This is the single most common frustration in WordPress forums. You add the line to wp-config.php, reload the site, and Site Health still shows 128M. Here is why, and what to do about it.

WordPress WP_MEMORY_LIMIT is a request for memory, not a guarantee. PHP will honor it only if the requested value is lower than or equal to the server’s memory_limit setting in php.ini. If the server is set to 128M and you ask for 256M, PHP silently keeps you at 128M.

To confirm you are hitting a host override, run the WP-CLI command above. If the returned value matches your host’s cap and not your wp-config.php value, the override is real.

The fix in this case is one of:

  • Use Method 3 or Method 4 to change memory_limit at the server level (you usually need the panel, since hosts often block direct edits to php.ini).
  • Open a support ticket using the script in Method 6.
  • Move to a host that does not artificially cap PHP memory.

A different override scenario: some managed hosts (WP Engine, Pressable) set a per-site PHP memory limit in their own dashboard that takes precedence over both wp-config.php and the global php.ini. The setting usually lives under Site → Utilities or Settings → Performance.

How to Prevent the WordPress Memory Exhausted Error From Coming Back

Raising the limit is a temporary fix. To make it stick, address the root cause. Over the years I have seen the same handful of culprits account for almost every recurring memory error.

Audit your plugins. A single poorly coded plugin can consume the entire memory budget on a small site. Deactivate plugins one by one and watch when the error disappears – the last one you deactivated is usually the culprit. The Health Check & Troubleshooting plugin and Query Monitor both expose per-plugin memory usage and slow queries. Reviewers on the r/Wordpress subreddit consistently recommend this exact diagnosis flow.

Optimize images and media. Large unoptimized images force PHP to allocate big buffers during upload and resizing. Run a compression pass with ShortPixel, Imagify, or Smush. Limit the maximum upload size to a reasonable value (around 10MB) in Settings → Media.

Install a caching plugin and a CDN. WP Rocket, LiteSpeed Cache, and W3 Total Cache all reduce the work PHP has to do on each request by serving cached HTML. Cloudflare’s free tier adds a CDN in front of your site, offloading traffic before PHP is involved at all.

Update PHP. Each PHP 8.x release is meaningfully faster and more memory-efficient than its predecessor. PHP 7.4 and earlier are end-of-life, and many hosts default to PHP 8.1 or 8.2 now. Check your version under Tools → Site Health → Server and switch if you are stuck on an old version.

Consider a hosting upgrade. If you are on a budget shared plan and your site has grown past a handful of plugins, the limits themselves are the bottleneck. Managed WordPress hosting starts at reasonable monthly prices and ships with 256M to 512M PHP memory as a baseline, plus caching and a CDN already configured.

Distinguish a leak from a capacity issue. If the error returns even at 1024M on a simple site, the cause is almost certainly a memory leak in a plugin or theme. The Beaver Builder community regularly confirms this pattern: “That error means your site has reached the maximum amount of memory it can use. That’s the PHP memory limit, not the WordPress one.” In other words, no amount of raising the limit will fix a leak.

Frequently Asked Questions

How do I fix out of memory error in WordPress?

The fastest fix is to add define(‘WP_MEMORY_LIMIT’, ‘256M’); to your wp-config.php file just above the line that reads u0022That’s all, stop editing! Happy publishing.u0022 Save the file and refresh your site. If the error persists, raise the server-side memory_limit from cPanel’s MultiPHP INI Editor, hPanel, Plesk, or by editing php.ini or .user.ini on PHP-FPM hosts.

How do I increase the WP memory limit?

Open wp-config.php in your site root and add define(‘WP_MEMORY_LIMIT’, ‘256M’); just before the u0022That’s all, stop editing!u0022 comment. For admin-area errors, also add define(‘WP_MAX_MEMORY_LIMIT’, ‘512M’); directly below it. Use straight single quotes and end each line with a semicolon.

How do I check my current WordPress memory limit?

Go to Tools u0026gt; Site Health u0026gt; Info u0026gt; Server in your WordPress dashboard and look for the PHP memory limit row. For a precise value from the command line, run wp eval ‘echo ini_get(u0022memory_limitu0022);’ over SSH. You can also create a temporary phpinfo file to see every active PHP setting.

How much memory should I allocate to WordPress?

128M is enough for a small blog, 256M is the comfortable default for most business sites, 512M is recommended for WooCommerce stores, and 512M to 1024M is appropriate for LMS, membership, or multi-vendor marketplaces. Going above 1024M rarely helps and can hide an underlying memory leak in a plugin or theme.

Why does my wp-config edit not raise the memory limit?

WordPress WP_MEMORY_LIMIT is only a request, and PHP will silently cap it at whatever the server-side memory_limit is set to in php.ini. If your host enforces a lower value, your wp-config edit has no effect. The fix is to raise the server-side memory_limit from your hosting control panel, edit php.ini or .user.ini, or contact your host.

Is it safe to increase the PHP memory limit manually?

Yes, raising WP_MEMORY_LIMIT in wp-config.php is safe and is the recommended first step. Take a full backup before editing core files, use straight single quotes inside define(), and end the line with a semicolon. Avoid editing functions.php for this, since the change is overwritten on every theme update.

Conclusion + Next Steps

You now have six reliable ways to fix the WordPress memory exhausted error: edit wp-config.php, edit .htaccess, edit php.ini, use your hosting panel, use .user.ini on PHP-FPM hosts, or contact your host. For most sites, Method 1 alone is enough. For PHP-FPM hosts, Method 5 is the safer choice. For shared hosts that cap memory aggressively, Method 6 is usually the only path forward.

After you make the change, verify the new limit using Site Health or the WP-CLI command covered above. If the value did not move, your host is enforcing a cap and you will need to open a support ticket or upgrade your plan.

Once the error is gone, take an hour to audit your plugins, optimize your images, install a caching plugin and CDN, and confirm you are on a current PHP version. Those four steps prevent the memory exhausted error from sneaking back days later, which is the most common complaint I see on forums. If you keep hitting the error at very high limits on a small site, treat it as a memory leak and isolate the offending plugin before you raise the limit any further.

Leave a Comment