WORDPRESS TROUBLESHOOTING
How to Fix the WordPress PHP Memory Limit Error

If your WordPress website displays an “Allowed memory size exhausted” error, PHP has reached the amount of memory available to complete the requested process. This can happen during plugin or theme updates, page editing, image processing, imports, backups, or other resource-intensive operations.
In this guide, we’ll show you how to increase the WordPress PHP memory limit and what to check if increasing the limit doesn’t resolve the problem.
What Is the WordPress PHP Memory Limit?
PHP uses memory while WordPress executes code and processes requests. The PHP memory limit determines how much memory an individual PHP process is allowed to consume.
WordPress also provides two configuration constants:
WP_MEMORY_LIMIT controls the memory WordPress requests for normal operations.
WP_MAX_MEMORY_LIMIT controls the higher memory limit WordPress can request for administrative and other memory-intensive operations.
Your hosting environment ultimately determines how much PHP memory is actually available. Setting a higher value in WordPress cannot override a lower server-level restriction if the host does not allow it.
Common Signs of a PHP Memory Limit Problem
A memory issue may appear as the familiar:
Fatal error: Allowed memory size of XXXXX bytes exhausted
But depending on the site and hosting configuration, you might instead encounter an HTTP 500 error, a blank page, a failed plugin or theme operation, or an error recorded only in the server logs. WP Engine documents these as common outcomes of PHP memory exhaustion.
How to Increase the WordPress Memory Limit
Before editing WordPress configuration files, create a backup of the website.
Connect to the website through SFTP, SSH, your hosting file manager, or another method provided by your hosting company.
Locate: wp-config.php
Add the following before WordPress finishes loading its configuration:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
The first setting allows WordPress to request up to 256 MB for normal operations. The second allows WordPress to request up to 512 MB for administrative operations that may require additional memory.
Save the file and test the operation that previously generated the error.
Important
Do not assume that setting 512M means WordPress will automatically receive 512 MB.
The server’s PHP configuration and hosting environment determine the maximum memory available. Some hosting providers restrict these settings or require memory limits to be changed through their hosting control panel or support team.
If Your Website Is Hosted on WP Engine
WP Engine currently allows the WordPress memory limit to be configured up to 512 MB.
Its current platform documentation allows:
define( ‘WP_MEMORY_LIMIT’, ‘512M’ );
and, when a separate administrative limit is needed:
define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
WP Engine recommends placing custom entries in the WP Engine Settings section of wp-config.php.
For a typical site, however, I would start with:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
rather than automatically allocating the maximum value everywhere.
What If Increasing the Memory Doesn’t Fix the Error?
If the memory exhaustion error continues after increasing the limit, don’t keep increasing memory.
The site may have an underlying problem causing excessive memory consumption.
Common causes can include:
For troubleshooting, create a staging copy of the website and test there rather than disabling plugins or changing themes directly on the production site.
WP Engine similarly recommends testing plugins and themes individually in a staging or development environment when memory errors continue after the limit has been increased
A PHP memory limit error does not always mean the website simply needs more memory.
Increasing the limit is an appropriate first troubleshooting step, but if the error returns, investigate what is consuming the memory. A plugin, theme, custom function, database query, or other process may be using resources inefficiently.


