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

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

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.

Common default memory limits:

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, which was sufficient years ago but often not enough for modern WordPress sites
  • Too many plugins running simultaneously — Sites with 20, 30, or more plugins can easily exceed modest memory limits
  • Resource-heavy plugins — Page builders like Elementor, WooCommerce, SEO plugins, and backup plugins all consume significant memory
  • Large media imports or data processing — Importing a large CSV, processing batch images, or running large WooCommerce exports can spike memory temporarily
  • Poorly coded plugins or themes — A plugin with a memory leak that continuously allocates memory without releasing it can exhaust even a generous 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

  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

Method 2: Create a temporary phpinfo file

  1. Create a file called phpinfo.php in your WordPress root directory via FTP
  2. Add this single line: <?php phpinfo(); ?>
  3. Visit https://yourdomain.com/phpinfo.php in your browser
  4. Search the page for memory_limit
Security Warning: Delete this file immediately after checking. Leaving phpinfo files on a live site is a serious security risk.

How to Fix the WordPress Memory Exhausted Error

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.

Step 1: Connect to your server via FTP or open your hosting file manager

Step 2: Open wp-config.php from your WordPress root directory

Step 3: Find this comment near the bottom of the file:

PHP — wp-config.php
/* That's all, stop editing! Happy publishing. */

Step 4: Add this line directly above that comment:

PHP — wp-config.php
define( 'WP_MEMORY_LIMIT', '256M' );

Step 5: Save the file and reload your website.

For wp-admin specifically, you can also add a second line:

PHP — wp-config.php
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

WP_MAX_MEMORY_LIMIT applies to admin-side operations, while WP_MEMORY_LIMIT applies to front-end page loads.

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 in the WordPress root directory:

Apache — .htaccess
php_value memory_limit 256M
Note: 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 over the memory limit — but not all hosting plans allow you to modify it.

Option A: Local php.ini in WordPress root:

  1. Connect via FTP and check if a php.ini file already exists in your WordPress root
  2. If it exists, open it and find the memory_limit line and change its value to 256M
  3. If no php.ini exists, create one with this single line: memory_limit = 256M
  4. Save and upload to your WordPress root directory

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

Bash
# Find the php.ini location
php --ini

# Open it in an editor
sudo nano /etc/php/8.1/apache2/php.ini

# Update the memory_limit
memory_limit = 256M

# Restart 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 memory_limit and change the value to 256M
  4. Click Save Changes

In Plesk:

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

In SiteGround Site Tools:

  1. Go to Devs → PHP Manager
  2. Select your PHP version
  3. Click PHP Variables tab
  4. 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.

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 (e.g., 64 MB on a very restrictive plan), it may be time to upgrade your hosting plan or switch providers.

Pro Tip: Memory errors that keep returning after setting WP_MEMORY_LIMIT mean your hosting provider's server-side configuration overrides your local settings. Try the next method in the list — some hosting environments prioritise certain configuration files over others.

After Increasing the Memory Limit: Verify It Worked

  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 (loading the page, running the import, etc.)

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

Increase 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 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. Lightweight themes like GeneratePress or Astra have 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. Query Monitor shows you exactly which plugins and processes are consuming the most RAM.
  • Optimise WooCommerce. WooCommerce is memory-intensive by nature. Use a dedicated WooCommerce caching solution and avoid too many extension plugins.
  • Switch to a better hosting plan. If your site needs 512 MB+, 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 gateways256 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 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 / SiteGround / CloudwaysNon-technical users with supported hosts
Contact hosting providerSupport ticketWhen 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 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 VPS or dedicated server, setting 512 MB or higher is perfectly safe and often necessary for complex sites. On shared hosting, check with your host first — they may cap you regardless of what you set.
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 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 returning after increasing the 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 for your site's needs.

Need help diagnosing persistent memory issues or optimising your WordPress site for better performance? Our team of WordPress developers can audit your setup and recommend the right fix.

Contact us today
Views: 162