How to Fix WordPress Memory Exhausted Error (Increase PHP Memory)

You're working inside your WordPress dashboard — installing a plugin, running an import, or simply loading a page — and suddenly you see this:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /wp-includes/...

Or your site throws a White Screen of Death with no visible message at all.

This is the WordPress Memory Exhausted Error — and it means PHP ran out of the memory it was allocated to run your WordPress site and stopped dead in its tracks.

It's one of the most common WordPress errors, especially on shared hosting plans — and it's almost always fixable in under five minutes. This guide covers every method to increase your PHP memory limit, from the simplest one-line fix to server-level solutions.

What Is the WordPress Memory Exhausted Error?

Every time someone loads a page on your WordPress site, PHP executes code — loading WordPress core, your active theme, every active plugin, and the content from your database — all in memory.

Your hosting server allocates a fixed amount of RAM for each PHP process. This is called the PHP memory limit. If your WordPress installation tries to use more memory than this limit allows, PHP throws a fatal error and stops executing.

The error message looks like one of these:

  • Fatal error: Allowed memory size of X bytes exhausted
  • Fatal error: Out of memory (allocated X) (tried to allocate X bytes)
  • PHP Fatal error: Allowed memory size of 33554432 bytes exhausted

Or it may produce no visible message at all — just a White Screen of Death or a 500 Internal Server Error.

The number in the message is the current memory limit in bytes:

Bytes Equivalent
3355443232 MB
6710886464 MB
134217728128 MB
268435456256 MB

WordPress officially recommends a minimum of 64 MB, and for most modern sites with multiple plugins, 256 MB is a more realistic requirement.

What Causes the WordPress Memory Exhausted Error?

  • Default PHP memory limit is too low — Many shared hosting providers set the default at 32 MB or 64 MB. This was sufficient years ago but is often not enough for modern WordPress sites
  • Too many plugins running simultaneously — Every active plugin consumes memory. Sites with 20, 30, or more plugins can easily exceed modest memory limits
  • Resource-heavy plugins — Page builders like Elementor, WooCommerce, SEO plugins like Yoast, and backup plugins all consume significant memory
  • Large media imports or data processing — Importing a large CSV, processing a batch of images, or running a large WooCommerce order export can spike memory usage temporarily
  • Poorly coded plugins or themes — A plugin or theme with a memory leak — code that continuously allocates memory without releasing it — can exhaust even a generous memory limit
  • WordPress core update — Major WordPress updates temporarily require more memory than usual during the upgrade process

How to Check Your Current PHP Memory Limit

Method 1: Via WordPress admin (easiest)

  1. Log in to your WordPress dashboard
  2. Go to Tools → Site Health
  3. Click the Info tab
  4. Expand the Server section
  5. Look for PHP memory limit — this shows your current limit

Method 2: Create a temporary phpinfo file

  1. Create a new file called phpinfo.php in your WordPress root directory via FTP
  2. Add this single line:
PHP
<?php phpinfo(); ?>
  1. Visit https://yourdomain.com/phpinfo.php in your browser
  2. Search the page for memory_limit
  3. Delete this file immediately after checking
Security Warning: Leaving phpinfo files on a live site is a serious security risk — it exposes your entire server configuration. Always delete it immediately after checking.
01
Edit wp-config.php (Easiest and Most Reliable)

This is the recommended first approach. Adding a single line to wp-config.php tells WordPress to request more memory from PHP.

  1. Connect to your server via FTP or open your hosting file manager
  2. Navigate to your WordPress root directory
  3. Open wp-config.php
  4. Find this comment near the bottom of the file:
PHP
/* That's all, stop editing! Happy publishing. */
  1. Add this line directly above that comment:
PHP
define( 'WP_MEMORY_LIMIT', '256M' );
  1. Save the file and reload your website

For wp-admin specifically, add a second line for admin operations (imports, updates, media processing):

PHP
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
How it works: WP_MEMORY_LIMIT applies to front-end page loads. WP_MAX_MEMORY_LIMIT applies to admin-side operations. WordPress passes these requests to PHP, which honours them up to the server's maximum allowed limit.
02
Edit the .htaccess File

If editing wp-config.php didn't work — or if your host requires memory limits to be set at the Apache level — add this line to your .htaccess file:

Apache
php_value memory_limit 256M

Open .htaccess via FTP (remember to show hidden files), add the line near the top of the file above the # BEGIN WordPress block, and save.

Important: This method only works on Apache servers where PHP runs as an Apache module. On servers using PHP-FPM (common on Nginx and many modern hosting setups), this line will either be ignored or cause a 500 error. If adding it causes a new error, remove it immediately.
03
Edit php.ini

The php.ini file is PHP's main configuration file. Editing it directly gives you the most control — but not all hosting plans allow you to modify it.

Option A: Create a local php.ini in your WordPress root

Some hosting providers allow a local php.ini that overrides the server's global settings:

INI
memory_limit = 256M

Create this file and upload it to your WordPress root directory via FTP.

Option B: Edit the global php.ini (VPS and dedicated servers)

If you have root access to your server:

Bash
# Locate the php.ini file
php --ini

# Open the file
sudo nano /etc/php/8.1/apache2/php.ini

# Find and update the line
memory_limit = 256M

# Save and restart your web server
sudo systemctl restart apache2
# or for Nginx with PHP-FPM:
sudo systemctl restart php8.1-fpm
04
Use Your Hosting Control Panel

Many hosting providers let you change the PHP memory limit directly from the control panel — no file editing required.

In cPanel:

  1. Log in to cPanel
  2. Look for "Select PHP Version", "PHP Configuration", or "MultiPHP INI Editor"
  3. Find the memory_limit setting
  4. Change it to 256M or 512M
  5. Save changes

In Plesk:

  1. Go to Websites & Domains → PHP Settings
  2. Find memory_limit and update the value
  3. Click Apply

In SiteGround Site Tools:

  1. Go to Devs → PHP Manager
  2. Select your PHP version → click PHP Variables tab
  3. Find memory_limit and increase the value

In Cloudways:

  1. Go to Application Settings → PHP FPM Settings
  2. Find memory_limit and increase it
  3. Save and restart the PHP-FPM service
05
Contact Your Hosting Provider

If none of the above methods work, your hosting plan likely has a hard server-side cap on PHP memory that cannot be overridden from within WordPress or configuration files.

This is common on entry-level shared hosting plans. When you contact your hosting provider, ask them:

  • "What is the maximum PHP memory limit allowed on my plan?"
  • "Can you increase my PHP memory limit to 256 MB?"

Most good hosts will either increase the limit for you or tell you what their maximum is. If their maximum is still insufficient, it may be time to upgrade your hosting plan or switch providers.

Signs your hosting plan's memory limit is too low:

  • Memory errors appear repeatedly even after setting WP_MEMORY_LIMIT in wp-config.php
  • The Site Health tool shows a low PHP memory limit that doesn't change after your edits
  • Your host confirms they cannot increase the limit on your current plan

After Increasing the Memory Limit: Verify It Worked

After applying any of the methods above, verify the new limit is actually in effect:

  1. Go to Tools → Site Health → Info → Server in your WordPress dashboard
  2. Check the PHP memory limit value — it should reflect your new setting
  3. Try the action that was triggering the memory error
If the Site Health panel still shows the old limit, the change didn't take effect. Try the next method in the list — some hosting environments prioritise certain configuration files over others.

Fixing the Root Cause: Reducing Memory Usage

Increasing the memory limit solves the immediate error — but if your site is genuinely pushing against memory limits, it's worth also addressing the root cause.

  • Deactivate and delete unused plugins. Every active plugin consumes memory whether you actively use it or not. Audit your plugins and remove anything you don't need
  • Switch to a lighter theme. Feature-heavy themes with built-in page builders can consume as much memory as several plugins. A lightweight theme like GeneratePress or Astra has a fraction of the memory footprint
  • Identify memory-hungry plugins with Query Monitor. Install the free Query Monitor plugin and load a page that was throwing memory errors. It shows you a memory usage breakdown — exactly which plugins and processes are consuming the most RAM
  • Optimise WooCommerce if you're running a store. WooCommerce is memory-intensive by nature. Use a dedicated WooCommerce caching solution and avoid running too many WooCommerce extension plugins simultaneously
  • Switch to a better hosting plan. If your site has grown to the point where 256 MB is not enough, you've outgrown shared hosting. A managed WordPress host or VPS gives you dedicated resources and much more headroom

How Much PHP Memory Does WordPress Actually Need?

Site Type Recommended Memory Limit
Simple blog or brochure site (5–10 plugins)128 MB
Business site with contact forms, SEO, caching (10–20 plugins)256 MB
WooCommerce store with payment gateways and extensions256 MB – 512 MB
Membership site or LMS with many concurrent users512 MB+
High-traffic site with page builder, SEO, and custom functionality512 MB+

When in doubt, 256 MB is a safe all-round starting point for most WordPress sites.

Quick Reference: Memory Exhausted Error Fix Summary

Method Where to Edit Best For
Add WP_MEMORY_LIMIT to wp-config.phpwp-config.phpAll WordPress sites — try this first
Add php_value to .htaccess.htaccessApache servers with PHP as module
Edit or create php.iniWordPress root or serverHosts that support local php.ini
Use hosting control panelcPanel / Plesk / Host dashboardNon-technical users with supported hosts
Contact hosting providerSupport ticket or live chatWhen server has a hard cap you can't override

Frequently Asked Questions

Q: How do I know if increasing the memory limit worked?
A: Go to Tools → Site Health → Info → Server in your WordPress dashboard and check the PHP memory limit value. Alternatively, visit yourdomain.com/phpinfo.php (if you've created the temporary file) and search for memory_limit.
Q: Is it safe to set the PHP memory limit to 512 MB or higher?
A: Yes, as long as your server has enough physical RAM to support it. On a shared hosting plan with strict resource limits, your host may cap you regardless of what you set. On a VPS or dedicated server, setting 512 MB or higher is perfectly safe and often necessary for complex sites.
Q: Why does my memory limit keep reverting to the old value?
A: This happens when your hosting provider's server-side configuration overrides your local settings. In this case, you need to change the limit through your hosting control panel (cPanel/Plesk) or contact your host directly.
Q: Can a single plugin cause the memory exhausted error?
A: Absolutely. A plugin with a memory leak, a large operation (like a bulk import), or simply a very resource-heavy plugin can exhaust the limit on its own. Use Query Monitor to identify which plugin is consuming the most memory.
Q: Does increasing PHP memory improve my site speed?
A: Not directly. PHP memory limit is about how much RAM PHP can use — not how fast it runs. However, removing the memory bottleneck prevents crashes and can indirectly improve stability and response times on memory-constrained sites.

Final Thoughts

The WordPress Memory Exhausted Error is one of the most fixable problems in all of WordPress. In most cases, adding a single line to wp-config.php resolves it completely in under a minute.

If the error keeps coming back even after increasing the memory limit, that's a signal to investigate further — audit your plugins, profile your memory usage with Query Monitor, and consider whether your current hosting plan is adequately resourced.

Contact us today and we'll get your site running smoothly
Views: 106