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

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

The WordPress “Allowed memory size exhausted” error means your site has exceeded the PHP memory limit set by your server. The fastest fix is to add define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php file, which increases the memory WordPress is allowed to use. This resolves the error in most cases within 60 seconds.

The full error message typically reads something like: “Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 2097152 bytes) in /home/user/public_html/wp-includes/some-file.php on line XX.” The number 67108864 bytes equals 64 MB — the default WordPress memory limit. The error means a WordPress process (loading a page, running a plugin, processing an image upload) tried to use more memory than 64 MB, and PHP killed it.

This error commonly appears when uploading large images or media files, running resource-heavy plugins (page builders, backup plugins, import tools), loading pages with many active plugins, running WooCommerce with large product catalogues, and during WordPress updates or database operations.

What Causes the Memory Exhausted Error?

Default memory limit is too low. WordPress sets a default memory limit of 40 MB for front-end operations and 256 MB for admin operations. Many hosting providers override this with their own limits — often 64 MB or 128 MB on shared hosting plans. As WordPress sites grow more complex with more plugins and themes, these limits become insufficient.

Memory-hungry plugins. Some plugins consume significantly more memory than others. Page builders like Elementor and Divi load substantial frameworks. Backup plugins need memory to compress files. Image optimization plugins process large files in memory. WooCommerce with many products runs complex database queries that consume memory.

Poorly coded plugins or themes. A plugin with memory leaks — code that allocates memory but never releases it — can exhaust available memory even when the limit is set generously. This is less common but more difficult to diagnose.

Large media uploads. Uploading a high-resolution image (10 MB+ JPEG from a modern camera) requires WordPress to load the entire image into memory, generate multiple thumbnail sizes, and sometimes apply filters — all of which consume memory proportional to the image’s pixel dimensions.

Method 1: Increase Memory in wp-config.php (Recommended)

This is the most reliable method and the one we recommend trying first. Open your wp-config.php file via FTP, SFTP, or your hosting file manager. Find the line that says /* That's all, stop editing! Happy publishing. */. Add the following line immediately ABOVE that comment:

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

Save the file and reload your site. In most cases, this immediately resolves the error.

If you need to increase the admin memory limit specifically (for operations in the WordPress dashboard), also add:

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

The WP_MEMORY_LIMIT controls front-end memory (what visitors use). WP_MAX_MEMORY_LIMIT controls admin-side memory (what you use in the dashboard). Both can be set independently.

Method 2: Increase Memory via .htaccess

If modifying wp-config.php does not work — which can happen when your hosting provider enforces memory limits at the server level — try adding a PHP directive to your .htaccess file. Open .htaccess in your WordPress root directory and add this line at the top:

php_value memory_limit 256M

Save and reload. Note: this method only works on Apache servers. If your site runs on Nginx or LiteSpeed, this directive will have no effect (and on Nginx, it may cause a 500 error — remove it if that happens).

Method 3: Increase Memory via php.ini

Some hosting environments respect a php.ini file in your WordPress root directory. Create a file named php.ini (or .user.ini on some hosts) in your WordPress root and add:

memory_limit = 256M

Save and upload. Not all hosting providers allow php.ini overrides — shared hosting in particular often ignores this file. If this method does not work, Method 4 is your next option.

Method 4: Increase Memory via Hosting Control Panel

Many hosting providers allow you to change PHP settings directly from your control panel. In cPanel, look for “MultiPHP INI Editor” or “PHP Configuration.” In Plesk, go to “PHP Settings.” In custom hosting panels, look for a “PHP” or “Server Configuration” section. Find the memory_limit setting and increase it to 256M or higher.

If your hosting control panel does not offer this option, contact your hosting provider’s support team and request that they increase your PHP memory limit. Most hosts will accommodate reasonable increases (256 MB is standard for WordPress sites).

Method 5: Contact Your Hosting Provider

On shared hosting plans, the memory limit is often enforced at the server level and cannot be overridden by any of the methods above. If you have tried Methods 1–4 and the error persists, contact your hosting provider. Explain that your WordPress site needs at least 256 MB of PHP memory. Most hosts will increase the limit upon request.

If your host refuses to increase the memory limit — or if their maximum is too low for your site’s needs — consider upgrading your hosting plan. VPS, cloud, and managed WordPress hosting plans typically offer 256 MB–1 GB of PHP memory. Shared hosting plans often cap at 128–256 MB. If your site consistently needs more than what your current host allows, it has outgrown shared hosting.

How to Find Which Plugin Is Using Too Much Memory

If the memory exhausted error persists even after increasing the limit to 256 MB or higher, a specific plugin or theme is consuming an unusual amount of memory. To identify the culprit:

Install the Query Monitor plugin. Query Monitor is a free debugging plugin that displays memory usage, database queries, and PHP errors in a developer toolbar. After installing it, the toolbar shows the total PHP memory used on each page load. Navigate to the pages where the error occurs and check which plugins consume the most memory.

Use the process of elimination. Deactivate all plugins. Check if the memory error stops. Reactivate plugins one at a time, checking memory usage after each. When memory spikes dramatically after activating a specific plugin, you have found the memory hog. See our plugin conflict troubleshooting guide for the detailed process.

Common memory-heavy plugins include Elementor (especially with many widgets and templates), WPBakery Page Builder, WPML (multilingual plugin with large translation databases), WooCommerce with 1,000+ products, and backup plugins during backup execution (UpdraftPlus, BackupBuddy).

How to Reduce WordPress Memory Usage

Increasing the memory limit fixes the immediate error, but reducing memory consumption addresses the root cause and prevents the error from recurring as your site grows.

Deactivate and delete unused plugins. Every active plugin consumes memory, even if it does not appear to do anything on the current page. Remove plugins you are not actively using. Read our guide on choosing plugins without bloating your site.

Optimise your images before uploading. Resize images to the maximum dimensions your site actually displays (typically 1920px wide for full-width images) before uploading. A 6000×4000 pixel camera image requires WordPress to allocate far more memory for thumbnail generation than a pre-resized 1920×1080 image. See our image optimization guide.

Use a lightweight theme. Heavy multipurpose themes that bundle page builders, sliders, and dozens of features consume significantly more memory than lightweight, purpose-built themes. If your theme loads 15+ JavaScript files and 10+ CSS files on every page, it is likely a memory (and performance) issue.

Optimise your database. A bloated WordPress database with thousands of post revisions, expired transients, and orphaned metadata forces WordPress to load more data into memory during database operations. Regular database cleanup reduces memory consumption.

What Memory Limit Should You Set?

For most WordPress sites, 256 MB is the sweet spot — sufficient for the vast majority of plugin stacks and operations without being wastefully high. For WooCommerce stores with large catalogues, sites running Elementor or other page builders, and sites with many concurrent plugins, 512 MB may be necessary. For simple blogs and portfolio sites with a minimal plugin stack, 128 MB is often sufficient.

Setting the limit excessively high (2 GB+) on shared hosting can actually cause problems — your site might consume resources that affect other sites on the shared server, prompting your host to throttle or suspend your account.

Frequently Asked Questions

Is it safe to increase the PHP memory limit?

Yes. Increasing the memory limit does not change your site’s code or functionality — it simply allows WordPress to use more of your server’s available RAM. On a VPS or dedicated server, ensure you have enough total RAM to support the increase. On shared hosting, your host may limit how high you can set it regardless of what you put in wp-config.php.

I increased the memory limit but the error still appears. Why?

Three possibilities: your hosting provider is overriding your setting with a lower server-level limit (contact them to verify), the actual memory needed exceeds your new limit (try 512 MB or higher), or a plugin has a memory leak that will exhaust any reasonable limit (use Query Monitor to identify it).

The error only appears when I try to upload images. What is wrong?

Image processing (thumbnail generation) is one of the most memory-intensive operations in WordPress. Very large images (5000+ pixels wide, 10+ MB file size) can easily exhaust a 128 MB limit during processing. Increase your limit to 256 MB and resize images before uploading — most sites never display images wider than 1920 pixels.

Will upgrading my hosting plan fix this permanently?

Usually yes. Moving from shared hosting (typically 64–128 MB limit) to managed WordPress hosting or a VPS (256 MB–1 GB+ limit) provides significantly more memory headroom and eliminates the most common trigger for this error. Our migration service can help you move to a better hosting environment without downtime.

Need Expert Help? Let WP Ministry Handle It

Memory exhausted errors can be a one-time fix or a symptom of deeper issues — an inefficient plugin stack, a poorly coded theme, or hosting that has outgrown your site’s needs. Our 24/7 team diagnoses and resolves these issues as part of every care plan. We also monitor your site’s resource usage proactively, catching memory problems before they crash your pages.

Call (901) 249-0909 for immediate assistance, or request a one-time fix starting at $199.

View our care plans →

Related Articles

How to Fix the WordPress White Screen of Death (Step by Step)

How to Fix WordPress 500 Internal Server Error (2026 Guide)

How to Fix WordPress “Maximum Execution Time Exceeded” Error

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment