How to Increase the WordPress Memory Limit (and When You Shouldn’t)

Key Takeaways
- ✓WordPress defaults to 40 MB on the front end and 256 MB in the admin.
- ✓WordPress can't use more than PHP's own memory_limit allows.
- ✓Tools → Site Health → Info shows both limits.
- ✓If a page needs hundreds of MB, find the plugin instead of raising the limit forever.
Table of Contents
- •How to Increase the WordPress Memory Limit (and When You Shouldn’t)
- •The Two Memory Limits
- •Step 1: Check Your Current Limits
- •Step 2: Raise WP_MEMORY_LIMIT in wp-config.php
- •Step 3: Raise PHP’s memory_limit
- •How Much Memory Does WordPress Need?
- •When Raising the Limit Is the Wrong Fix
- •Troubleshooting
- •Frequently Asked Questions
- •Room to Grow
How to Increase the WordPress Memory Limit (and When You Shouldn’t)
“Fatal error: Allowed memory size of 41943040 bytes exhausted” means a WordPress page needed more memory than PHP was allowed to give it. Raising the limit is usually a one-line change, but there are two limits involved, WordPress’s own and the server’s PHP limit, and raising the wrong one does nothing. This guide shows how to check both, how to raise them in every common setup, and how to tell when a higher limit is just hiding a heavy plugin.
Quick answer: add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above “That’s all, stop editing!”. If the error continues, raise PHP’s memory_limit in your hosting dashboard or php.ini, because WordPress can’t use more than PHP allows.
The Two Memory Limits
| Limit | Set in | Default |
|---|---|---|
WP_MEMORY_LIMIT (front end) | wp-config.php | 40 MB on a single site, 64 MB on multisite |
WP_MAX_MEMORY_LIMIT (admin) | wp-config.php | 256 MB |
PHP memory_limit | Server: php.ini, .user.ini, hosting dashboard | Set by your host |
WordPress defaults from the official wp-config.php documentation. WordPress asks PHP for its configured amount; if PHP’s own memory_limit is lower, PHP’s value wins. The 41943040 bytes in the error message above is exactly 40 MB, the WordPress default.
Step 1: Check Your Current Limits
Go to Tools → Site Health → Info:
Server section: “PHP memory limit” is the server’s
memory_limit.WordPress Constants section:
WP_MEMORY_LIMITandWP_MAX_MEMORY_LIMIT.
With WP-CLI: wp eval 'echo WP_MEMORY_LIMIT, " / ", ini_get("memory_limit");'.
Step 2: Raise WP_MEMORY_LIMIT in wp-config.php
Open wp-config.php in the site root and add, above the “That’s all, stop editing!” line:
define( 'WP_MEMORY_LIMIT', '256M' );To give the admin area more as well (for imports, page builders or WooCommerce reports):
define( 'WP_MAX_MEMORY_LIMIT', '512M' );Reload the page that failed. If the error now shows a bigger number that’s still exhausted, or Site Health still shows the old PHP limit, go to Step 3.
Step 3: Raise PHP’s memory_limit
Use whichever applies to your hosting:
Hosting dashboard: most managed hosts have a PHP settings page with a memory limit field. This is the safest option.
php.ini on a VPS: find the file with
php --ini(orphp-fpm -i | grep php.ini), setmemory_limit = 256M, then restart PHP-FPM or Apache..user.ini (PHP-FPM / CGI): create it in the site root with
memory_limit = 256M. Changes can take a few minutes to apply..htaccess (Apache with mod_php only):
php_value memory_limit 256M. On PHP-FPM this line causes a 500 error, so remove it if that happens.
Then check Site Health again to confirm the new value.
How Much Memory Does WordPress Need?
There’s no single right number; it depends on plugins and what the page does:
A simple blog or brochure site often runs well within 128 MB.
Page builders, WooCommerce and membership plugins commonly need 256 MB.
Large imports, image processing and big reports may need 512 MB in the admin.
Remember that this is per PHP process. With several PHP workers serving visitors at once, total memory use is roughly the per-request usage times the number of busy workers, which is why the server’s total RAM matters too.
When Raising the Limit Is the Wrong Fix
If a page needs hundreds of megabytes, something is usually wrong: a plugin loading huge datasets, an unbounded query, or a memory leak in a loop. Raising the limit hides it until traffic grows and the server runs out of RAM. Check:
The debug log (
WP_DEBUG_LOG) for the file named in the “exhausted” error. The path shows which plugin or theme is involved.Whether the error appears only on one page or action, which points to that feature.
Query Monitor (a free plugin) for memory use and slow queries per page.
Troubleshooting
The limit doesn’t change: your line is below the “stop editing” comment, or the host forces a maximum. Move the line up or ask your host.
500 error after editing .htaccess: the server runs PHP-FPM, not mod_php. Remove the
php_valueline.Out of memory even with a high limit: the server itself is out of RAM. Look for the out-of-memory killer in
dmesgon a VPS, or move to a plan with more memory.
Frequently Asked Questions
What is the default WordPress memory limit?
40 MB for a single site and 64 MB for multisite on the front end, and 256 MB for the admin area (WP_MAX_MEMORY_LIMIT), according to WordPress’s documentation.
Why didn’t WP_MEMORY_LIMIT work?
WordPress can’t exceed PHP’s own memory_limit. Raise PHP’s limit in your hosting dashboard, php.ini or .user.ini as well.
Is 256M enough for WordPress?
For most sites, including WooCommerce stores, yes. Imports and heavy admin tasks may need more through WP_MAX_MEMORY_LIMIT.
Does a higher memory limit make WordPress faster?
No. It only allows a request to use more memory before failing. Speed comes from caching, fewer heavy plugins and enough CPU.
Can a high memory limit crash my server?
It can if many requests use that much at once and the server runs out of RAM. Set a sensible limit and fix plugins that need excessive memory.
Room to Grow
Each RackUp Cloud WordPress site runs in its own container with 1 GB of dedicated RAM and 2 vCPU, with PHP settings and PHP 8.2 to 8.5 in the dashboard, for $2.49 a month. Busy stores can move up to Enterprise WordPress VPS with 4 GB RAM for $25 a month. See plans. More fixes: common WordPress errors.
Unsure Which Cloud Hosting Plan Fits Your Site?
Answer 4 quick diagnostic questions to estimate the server CPU, RAM and storage you need with transparent pricing.
Cloud Infrastructure Engineer.
Related Posts
WordPress HostingCommon WordPress Errors and How to Fix Them
The WordPress errors you are most likely to see, what each one means, and the fix that works most often, with links to full step-by-step guides.
WordPress HostingHosting for Agencies: How to Host Client Websites Without the Headaches
Reseller hosting, one big VPS, premium agency plans or one container per client: how each agency hosting setup affects your margin, support time and risk.
WordPress HostingSiteGround Alternatives (2026): Managed WordPress Hosting Without the Renewal Jump
SiteGround's intro prices jump at renewal. Here are its 2026 prices and the managed WordPress alternatives worth comparing, with an honest look at the trade-offs.