The "Allowed memory size exhausted" fatal error is one of the most common ways a WordPress site breaks on any host, and it looks scarier than it is. This Ultra Web Hosting guide explains exactly what the error means, how to confirm it really is a memory problem, and the correct order in which to raise the limits. Just as important, it covers when raising the number is the wrong move and you should instead hunt down the plugin or query that is eating all your memory in the first place.
- What the Memory Exhausted Error Actually Means
- How the Error Shows Up on Your Site
- Confirm It Is a Memory Error, Not Something Else
- The Layered Limits: PHP vs WordPress
- Method 1: Raise the Limit in wp-config.php
- Method 2: Raise PHP memory_limit in cPanel
- Alternative: php.ini and .user.ini
- The Caveat: Find the Culprit, Do Not Just Raise the Number
- Memory Limit vs Resource Limit (508/503)
Raise WordPress First, Then PHP, Then Investigate
Almost every case is fixed by two lines in wp-config.php or one setting in cPanel. But if a single ordinary page keeps demanding more than 512M, the real problem is a plugin, an import, or a runaway query, and no amount of raising the ceiling will fix that for long.
- Add
WP_MEMORY_LIMITandWP_MAX_MEMORY_LIMITto wp-config.php - Raise PHP
memory_limitin cPanel MultiPHP INI Editor if needed - Your plan has a hard ceiling you cannot exceed
- If 512M is not enough, deactivate plugins to find what is wrong
A High Number Is Not a Fix
The single most common mistake is treating the memory limit like a volume knob and cranking it to 1024M or higher to make the error go away. That masks a bad plugin or an infinite loop instead of fixing it, and it puts your whole account at risk of hitting its resource ceiling. A normal WordPress page should run comfortably in 128M to 256M. If yours does not, Section 08 shows you how to find out why.
- Symptom: the error returns at a higher number a week later
- Cause: a plugin, theme, or query with a genuine memory bug
- Fix: isolate the culprit, do not keep feeding it memory
01. What the Memory Exhausted Error Actually Means
WordPress runs on PHP, and every PHP process on the server is allowed to use only so much memory before it is killed. When a page load tries to use more than that ceiling, PHP stops it dead and writes a message that reads something like this:
Fatal error: Allowed memory size of 268435456 bytes exhausted
(tried to allocate 20480 bytes) in
/home/youracct/public_html/wp-includes/class-wp-query.php on line 3456
The number 268435456 is bytes, which works out to 256M. It means the process asked for a little more memory, the account or server said no, and the request was killed mid-run. The file and line at the end tell you where PHP happened to be when it ran out, but that is rarely the true cause. It is simply where the last straw landed. This most often happens on a heavy plugin operation, a large import or backup, a bloated wp-admin page such as the plugins or updates screen, or a WooCommerce store rebuilding its catalog.
The word "fatal" here is standard PHP terminology, not a sign your site is damaged. Nothing was deleted or corrupted. The request was stopped part way through, which is why the page comes back blank or half-rendered. Fix the limit or the cause and the site behaves normally again.
02. How the Error Shows Up on Your Site
Depending on your WordPress version and debug settings, a memory exhaustion event wears one of three faces:
- The raw fatal error printed on a white background, exactly like the block above. This happens when debug display is on or the error is thrown before WordPress can catch it.
- A blank white page with no text at all. PHP hit the ceiling and died, and display of errors is off, so you get nothing. This is the classic White Screen of Death. Our guide "How to Fix the WordPress White Screen of Death" walks through it, and memory exhaustion is one of its top causes.
- The generic "There has been a critical error on this website" message. Modern WordPress traps the fatal error and shows this friendly page instead of a blank screen, usually with an email to the admin address. Our guide "How to Fix There Has Been a Critical Error on This Website" covers reading that email, which frequently points straight at a memory limit.
All three can be the same underlying memory problem. The only way to be sure is to read the actual error, which is the next section.
If the site only breaks in wp-admin (for example when opening Plugins or running an update) but the public homepage still loads, that is a strong hint you are hitting the memory ceiling on an admin-heavy page. The admin area routinely needs more memory than the front end, which is exactly why WordPress has a separate higher limit for it. See Section 04.
03. Confirm It Is a Memory Error, Not Something Else
Before changing any limits, confirm memory is genuinely the problem. A white screen or critical error can also come from a PHP syntax error, a broken plugin update, or the wrong PHP version. Turn on the debug log and read it.
Add these lines to wp-config.php, just above the line that reads /* That's all, stop editing! Happy publishing. */:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
- Edit
wp-config.phpin the root of your WordPress install, using cPanel File Manager or FTP. - Add the three lines above, then save.
- Reload the page that breaks so the error is logged.
- Open
wp-content/debug.logand read the most recent entry. A memory problem readsPHP Fatal error: Allowed memory size of ... bytes exhausted. - When you are done, set
WP_DEBUGback tofalseso errors are not logged in the open on a live site.
Keep WP_DEBUG_DISPLAY set to false on any production site. Printing errors to the screen leaks file paths and other details to visitors. The log file captures everything you need without showing it publicly. Remove or disable the debug lines once you have your answer.
04. The Layered Limits: PHP vs WordPress
There is more than one memory limit in play, and understanding how they stack is the key to fixing this cleanly. Two layers matter.
The PHP limit (memory_limit) is set at the server and account level. It is the true hard ceiling. No WordPress setting can raise your effective memory above what PHP allows, and PHP itself is capped by what your hosting plan permits.
The WordPress limits (WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT) are WordPress asking PHP for a working budget. WP_MEMORY_LIMIT applies to the front end and defaults to 40M. WP_MAX_MEMORY_LIMIT applies to the admin area and defaults to 256M, because admin tasks are heavier. WordPress uses these to call PHP's own memory function, but it can only ask for what PHP is willing to give.
The Server Ceiling
Set in cPanel or php.ini. This is the real maximum. Your plan caps how high it can go.
- Controlled in MultiPHP INI Editor
- Applies to all PHP on the account
- Cannot be exceeded by any WordPress define
The Request Budget
Set in wp-config.php. WordPress asks PHP for this much, up to the PHP ceiling. Separate values for front end and admin.
WP_MEMORY_LIMITfor the front endWP_MAX_MEMORY_LIMITfor wp-admin- Only effective up to the PHP limit
The practical upshot: raising the WordPress values does nothing if PHP is already lower. If WP_MEMORY_LIMIT is 256M but PHP memory_limit is 128M, you still cap at 128M. Fix them in the right order, WordPress first because it is the easiest, then PHP if that is not enough.
05. Method 1: Raise the Limit in wp-config.php
This is the first thing to try and it fixes the majority of cases. You are telling WordPress to request more memory from PHP for both the front end and the admin area.
- Open
wp-config.phpin the root of your WordPress install with cPanel File Manager or FTP. - Add the two lines below above the line that sets the table prefix (
$table_prefix = 'wp_';). Placement matters: defines after WordPress has loaded are ignored. - Save the file and reload the page that was breaking.
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
$table_prefix = 'wp_';
Here WP_MEMORY_LIMIT raises the front-end budget to 256M, and WP_MAX_MEMORY_LIMIT raises the admin budget to 512M for heavier tasks like imports and updates. These are sensible values for a busy site. If the error was in wp-admin, the second line is the one doing the work.
Use the M suffix for megabytes and no space, exactly as shown. 256M is correct, 256 MB or 256000000 will not parse the way you expect. If the file already has a WP_MEMORY_LIMIT line, edit that one rather than adding a second.
06. Method 2: Raise PHP memory_limit in cPanel
If the wp-config.php change did not help, PHP itself is the ceiling and you need to raise memory_limit at the account level. On Ultra Web Hosting you do this in cPanel, no ticket required.
- Log in to cPanel and open MultiPHP INI Editor (under the Software section).
- In the Basic Mode tab, choose the domain for your WordPress site from the dropdown.
- Find
memory_limitand set it to a sensible value such as256Mor512M. - Click Apply. The change takes effect on the next page load.
- Reload the page that was breaking to confirm the error is gone.
While you are in cPanel, make sure the domain is running a current, supported PHP version, since an old version has a lower default and other limits. See Change PHP Version for how to select it, and Changing Maximum Upload Size and PHP Limits for the related settings that often need raising at the same time, such as upload_max_filesize and max_execution_time.
Every shared plan enforces a maximum memory_limit you cannot exceed, no matter what you type into the editor. If you set 1024M and it silently reverts or does not take effect, you have hit that cap. That is by design and it protects every account on the server. If your site genuinely needs more than the plan allows, the answer is to optimize the site or move to a larger plan, not to fight the cap. See Section 09.
07. Alternative: php.ini and .user.ini
If you prefer editing files, or you want the setting to travel with the site, you can set memory_limit in a php.ini or .user.ini file in your WordPress root instead of the cPanel editor. Both do the same job as the MultiPHP INI Editor and are still bound by your plan ceiling.
Create or edit a file named .user.ini in public_html (or your WordPress root) with this single line:
memory_limit = 256M
The .user.ini file is the right choice on most modern PHP handlers and applies to that directory and below. A traditional php.ini works too on some configurations. Changes to these files can take a few minutes to register because PHP caches them, so wait before deciding it did not work.
Only use one method at a time. If you set memory_limit in both the MultiPHP INI Editor and a .user.ini, the results can be confusing to reason about. Pick whichever fits your workflow and stick with it. For most people the cPanel editor in Section 06 is simplest.
08. The Caveat: Find the Culprit, Do Not Just Raise the Number
Here is the part most tutorials leave out. A normal WordPress page, even a busy one with a page builder and a dozen plugins, should render comfortably in 128M to 256M. If a single ordinary page keeps demanding 512M or more, that is not a limit you need to raise. It is a symptom that something is wrong: a bloated or badly written plugin, an infinite loop, an unoptimized database query looping over thousands of rows, or a theme loading its entire media library on every request.
Raising the ceiling to 1024M to silence the error just moves the wall back a few feet. The bad code keeps growing, and next week the error returns at the higher number. Worse, a runaway process now eats a gigabyte of your account's resources every time it runs, which drags down the rest of your site and can trip your account resource limits (Section 09).
Quick
Fixes the symptom in two minutes. Right answer when a legitimately heavy task (a big import, a backup) needs a one-time boost.
- Fast, no investigation needed
- Correct for genuinely heavy operations
- Wrong if the error keeps coming back higher
Correct
Fixes the cause so the site runs lean. Right answer when an ordinary page needs absurd amounts of memory.
- Deactivate plugins to isolate the offender
- The site stays fast and within resource limits
- Takes longer but the problem stays fixed
To find the culprit, use the standard plugin bisection method:
- Deactivate all plugins. If you can reach wp-admin, do it from the Plugins screen. If the admin is down, rename the
wp-content/pluginsfolder toplugins-offusing File Manager, which deactivates them all at once. - Confirm the error is gone. If the page now loads within a normal limit, one of the plugins is the cause.
- Reactivate one plugin at a time, reloading the problem page after each. When the memory error returns, the plugin you just enabled is your culprit.
- Decide what to do with it: update it, replace it with a lighter alternative, or contact its developer. Do not leave it running while masking the symptom with a huge limit.
- Check the theme too. Temporarily switch to a default theme like Twenty Twenty-Four to rule the theme out.
If you find yourself raising memory_limit a second or third time to keep the same page alive, stop. You are feeding a memory leak, not fixing it. Every raise makes the eventual crash bigger and pushes your account closer to its resource ceiling. Isolate the plugin or query first, then set a sane limit around it.
Once the site loads, keep it lean so this does not recur. Caching, image optimization, and a trimmed plugin list all cut memory use per request. See How to Optimize WordPress Performance for the full checklist.
09. Memory Limit vs Resource Limit (508/503)
It is worth being clear that a PHP memory fatal is not the same thing as an account resource limit, even though both can take a site down. They are different systems and they have different fixes.
- A PHP memory fatal ("Allowed memory size exhausted") is a single request exceeding
memory_limit. It is fixed by the methods in this guide: raise the limit or, better, fix what is eating it. - An account resource limit shows as a 508 Resource Limit Is Reached or sometimes a 503, and it means your whole account has hit its allowance for CPU, memory, entry processes, or I/O across all requests at once. This is throttling at the account level, not a single page running out of memory.
They are related in that a memory-hungry plugin causing repeated fatals will also drive your account toward its resource ceiling, so fixing the memory leak helps both. But if you are seeing 508 or 503 errors specifically, that is a separate topic. Read Resource Limit Reached (508 and 503 Errors) for how to diagnose and resolve those, including when the honest answer is that a growing site has outgrown its plan and it is time to upgrade.
If raising the memory limit as far as your plan allows still does not fix the fatal error, and Section 08 has not turned up a single bad plugin, the site may simply be doing too much for a shared plan. That is a normal stage of growth. Optimize what you can, then talk to us about a plan with a higher ceiling. A brief blank page from a memory fatal should also not be confused with a full HTTP Error 500, which has its own set of causes.
Still Hitting the Wall?
If you have raised the limits and worked through the plugin isolation and the memory error still will not clear, open a ticket. We can read the PHP error logs from the server side, tell you exactly which process is blowing the budget, and advise whether the fix is optimization or a larger plan.
Open a Support TicketQuick Recap: Fixing Memory Exhausted in Six Steps
If you only do six things from this guide, do these:
- Confirm it is memory by reading
wp-content/debug.logfor "Allowed memory size ... exhausted" rather than guessing. - Add the WordPress defines to
wp-config.phpabove the table prefix line:WP_MEMORY_LIMITat 256M andWP_MAX_MEMORY_LIMITat 512M. - Raise PHP memory_limit in cPanel MultiPHP INI Editor if the WordPress change was not enough, remembering your plan has a hard ceiling.
- Do not endlessly raise the number. A normal page should run in 128M to 256M, so a page needing far more has a real bug.
- Find the culprit by deactivating all plugins and reactivating one at a time until the error returns, then fix or replace that plugin.
- Know the difference between a memory fatal and a 508/503 resource limit, and optimize or upgrade when the site has genuinely outgrown the plan.
Last updated July 2026 · Browse all WordPress articles
