Server Configuration Protocol
The WordPress memory exhausted error occurs when a PHP script exceeds the default memory limit allocated by your server. It triggers a fatal error on your screen or admin panel.
To resolve this error, define WP_MEMORY_LIMIT to 256M inside your wp-config.php file, update your .htaccess file with php_value directives, or increase limits in cPanel MultiPHP INI Editor.
- Default Limit: WordPress sets a basic 40MB limit for single sites, which modern builders quickly exhaust.
- Recommended Allocation: 256MB for content blogs; 512MB for WooCommerce and complex page builders.
- Primary Fix Location: wp-config.php directly above the Happy publishing comment line.
- Resolution Time: Less than three minutes using cPanel File Manager or SFTP.

Encountering a blank screen with a memory allocation fatal error can bring your publishing workflow to a halt. At BloggersNeed, our technical support team has diagnosed this exact bottleneck across hundreds of WordPress websites.
This error typically appears when editing complex pages in Elementor, uploading media files, or activating feature-heavy e-commerce plugins. It signals that your scripts need more operational RAM than your server allows.
In this comprehensive guide, we provide verified methods to increase your PHP memory limit. You will learn how to edit your configuration files safely, verify active limits, and prevent recurring memory leaks.
What Causes the WordPress Memory Exhausted Error?
The WordPress memory exhausted error happens when a PHP script demands more RAM than the memory_limit directive permits, triggering a Fatal error: Allowed memory size exhausted notice in your browser.
WordPress is built using the PHP server-side programming language. Every active plugin, installed theme template, and database query requires temporary memory to execute requests.
By default, WordPress automatically attempts to set its PHP memory limit to 40MB for single-site installations and 64MB for multisite networks. This default allocation was established over a decade ago.
Modern WordPress installations run resource-intensive tools like Gutenberg block suites, visual page builders, and analytics scripts. A modern site often requires at least 128MB to 256MB of RAM to render pages smoothly.

When a script attempts to allocate more RAM than the ceiling allows, PHP immediately halts execution to prevent server crashes. The server then outputs the fatal error message.
The error message specifies the exact memory threshold in bytes. For example, 41943040 bytes corresponds to 40MB, while 67108864 bytes corresponds to 64MB.
Method 1: Increasing PHP Memory Limit in wp-config.php
To raise your memory limit in wp-config.php, add define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); and define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ ); directly above the Happy publishing comment line.
Editing your wp-config.php file is the most reliable method for WordPress users because it overrides default core memory definitions directly within the application layer.
Log in to your hosting account and open cPanel File Manager, or connect to your server using an SFTP client like FileZilla. Navigate to your root directory, typically labeled public_html.
Locate the wp-config.php file in your root folder. Right-click the file and select Edit to open the code editor.

Scroll toward the bottom of the file until you locate the following comment line.
/* That's all, stop editing! Happy publishing. */
Paste the following two lines of code directly above that comment line.
/* Increase PHP Memory Limit */
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
The first line sets the memory limit for frontend visitor requests to 256MB. The second line sets the maximum memory limit for administrative backend tasks to 512MB.
Save the file and reload your WordPress dashboard. In most environments, this immediately resolves the fatal error.
Method 2: Modifying the Apache .htaccess File
To increase memory through Apache, insert php_value memory_limit 256M into your root .htaccess file. This instructs the web server to allocate extra memory before launching PHP processes.
If modifying wp-config.php does not clear the error, your web server configuration may be enforcing an external limit. In Apache environments, you can override this setting using .htaccess.
Open cPanel File Manager and navigate to your public_html folder. Ensure hidden files are visible by checking the Show Hidden Files option in File Manager settings.
Locate your .htaccess file, right-click, and select Edit.

Add the following directives to the bottom of the file, outside of the standard WordPress rewrite block.
# Increase PHP Memory Limit
php_value memory_limit 256M
php_value max_execution_time 300
Save your changes. If your website displays an HTTP 500 Internal Server Error after saving, your host runs PHP as FastCGI or PHP-FPM, which does not allow php_value in .htaccess.
If that occurs, remove those lines from .htaccess and proceed to the next method.
Method 3: Editing php.ini or cPanel MultiPHP INI Editor
To adjust server-wide PHP limits, navigate to MultiPHP INI Editor in cPanel, select your domain, and increase the memory_limit value to 256M or 512M before clicking Apply.
The php.ini configuration file governs master settings for the PHP runtime environment. On modern cPanel hosting, you can edit these directives through a graphical interface.
Log in to your hosting account and search for MultiPHP INI Editor in the cPanel search bar. Open the tool and select Basic Mode.
Choose your domain from the dropdown menu to load the current PHP directives.

Locate the line labeled memory_limit. Change the existing value from 64M or 128M to 256M or 512M.
While inside this editor, we also recommend increasing max_execution_time to 300 seconds. This prevents complex scripts from timing out while processing heavy data.
Click the orange Apply button at the bottom of the page to save your updated configuration.
How to Verify Your Active PHP Memory Limit in WordPress
To confirm your updated limit, navigate to Tools > Site Health in WordPress, open the Info tab, expand the Server section, and check the PHP memory limit metric.
Verifying your settings confirms whether your hosting environment accepted the new memory values. WordPress includes a built-in diagnostic screen for this purpose.
Open your WordPress administration dashboard. In the left navigation menu, click on Tools and select Site Health.
Click on the Info tab at the top of the screen. Scroll down and expand the Server accordion section.
Review the value listed under PHP memory limit. If the field displays 256MB or 512MB, your server has applied the increase.
If the field still displays 40MB or 64MB despite editing your configuration files, your web host enforces a hard limit at the account level. Contact hosting support to raise your account allocation.
How to Profile and Prevent Future Memory Leaks
To prevent future memory exhaustion, use the Query Monitor diagnostic plugin to detect RAM-heavy plugins, optimize autoloaded options in wp_options, and remove abandoned extensions.
Simply increasing memory limits does not solve underlying code inefficiencies. If a poorly coded plugin leaks memory, it will eventually exhaust even a 512MB ceiling.
Install the free Query Monitor plugin from the WordPress repository. When active, Query Monitor displays real-time memory usage and database query execution times in your admin toolbar.
Navigate through your pages and administrative screens. Review the peak memory metrics highlighted in red to identify which plugin consumes excessive memory.
Next, audit your database for bloated autoloaded options. Open phpMyAdmin, select your WordPress database, and run this SQL query to measure autoloaded data size.
SELECT SUM(LENGTH(option_value)) FROM wp_options WHERE autoload = 'yes';
If your autoloaded options exceed 1MB, clean up obsolete transients and orphaned data left by uninstalled plugins.
If memory exhaustion crashes your MySQL connection, follow our tutorial on how to fix the error establishing a database connection in WordPress to bring your site back online.
Finally, pair your performance optimizations with strong server-level defense. We recommend reviewing our tutorials on how to disable XML-RPC in WordPress and how to prevent PHP execution in WordPress uploads to keep your server fast and secure.
Frequently Asked Questions About WordPress Memory Limits
These practitioner answers address ideal memory allocations, potential risks of excessive RAM settings, differences between memory directives, and shared hosting limitations.
What is the recommended PHP memory limit for WordPress?
The recommended PHP memory limit is 256MB for standard blogs and 512MB for WooCommerce stores or sites built with Elementor.
Allocating 256MB ensures background cron tasks, backup plugins, and complex visual builders have sufficient operational memory without risking server-wide worker exhaustion.
Can increasing the PHP memory limit crash my web server?
Increasing your memory limit will not crash your server if your hosting plan has adequate total physical RAM installed.
However, if multiple simultaneous traffic spikes occur and each PHP worker consumes 512MB, a small server with only 1GB of total RAM can run out of system memory.
What is the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
The difference is that WP_MEMORY_LIMIT governs frontend requests, while WP_MAX_MEMORY_LIMIT controls heavy administrative backend tasks.
WordPress uses WP_MAX_MEMORY_LIMIT when executing resource-intensive operations in wp-admin, such as image processing, plugin installations, and database updates.
Why does my memory limit stay at 64M after editing wp-config.php?
Your limit stays unchanged because your hosting provider enforces a strict ceiling in the master server configuration.
On budget shared hosting, providers lock the PHP memory limit. You must upgrade your hosting tier or request support to permit higher allocations.

I’m Abdullah Prem, a passionate blogger with over 10 years of experience. I created BloggersNeed to produce high-quality, easy-to-understand articles, guides, and tutorials that help people start their blogging journey. Specializing in WordPress, Hosting, Themes, and online money-making strategies, I’ve been featured on leading tech platforms such as Tech.co, Cloudways, Business2Community, Leadpages, GoodFirms, and ShareThis. BloggersNeed.com