How to Increase the WordPress Memory Limit
To increase the WordPress memory limit, raise PHP's memory_limit to 256M in cPanel's MultiPHP INI Editor, then add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above the stop-editing comment. WordPress can lift PHP's limit only when the host allows it, so check the result under Tools › Site Health › Info.
For WordPress site owners and developers fixing the 'Allowed memory size exhausted' fatal error on shared or cPanel hosting.
knowledge
- Read time
- 5 min
- Sections
- 8
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 14 November 2026.
What does "Allowed memory size exhausted" mean in WordPress?
The error means one PHP request asked for more memory than the WordPress memory limit allowed, so PHP stopped it. The message gives the ceiling in bytes and the file that was running when it ran out, for example:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 2097152 bytes) in /home/user/public_html/wp-content/plugins/some-plugin/includes/export.php on line 412
268,435,456 bytes is exactly 256M (256 × 1,024 × 1,024). The path is the useful part: it names the plugin or theme folder that was working, not the page you happened to open. When the error appears also tells you a lot:
- On one action only (an import, a backup, a large image upload): a single heavy job; the site recovers when it ends.
- On every wp-admin screen: a page builder or plugin loading too much data on each load.
- At scheduled times: a WP-Cron task such as a backup or bulk email running at a busy hour.
Which memory settings control a WordPress site?
Three values decide the memory a WordPress request may use: PHP's memory_limit, WP_MEMORY_LIMIT for the front end and WP_MAX_MEMORY_LIMIT for admin tasks. Knowing which one is binding saves you from editing a file that cannot help.
| Setting | Set in | Applies to | Default |
|---|---|---|---|
| memory_limit | PHP: hosting panel, php.ini or .user.ini | Every PHP request on the account | Chosen by the host |
| WP_MEMORY_LIMIT | wp-config.php | Front-end page loads | 40M single site, 64M multisite |
| WP_MAX_MEMORY_LIMIT | wp-config.php | wp-admin, image editing, updates | 256M |
WordPress only ever raises memory, never lowers it. At start-up it compares WP_MEMORY_LIMIT with PHP's current memory_limit and, if its own value is higher, calls ini_set() to lift PHP to it. That works only when the host allows the change. If the host has locked memory_limit (for example with php_admin_value in the PHP-FPM pool, or by disabling ini_set), a wp-config value of 512M on a 128M server does nothing.
How do you raise memory_limit in cPanel?
Open cPanel's MultiPHP INI Editor, choose the domain and set memory_limit to 256M; this raises the real PHP ceiling and survives plugin and theme updates. On shared hosting it is the first change to make.
- In cPanel, go to Software › MultiPHP INI Editor.
- Stay on Basic Mode and pick the domain from the drop-down.
- Set
memory_limitto256M; use512Monly for a heavy WooCommerce or LMS site. - Click Apply.
- In wp-admin, open Tools › Site Health › Info › Server and read "PHP memory limit".
If the editor rejects the value or Site Health still shows the old one, the limit is fixed at server level and only the host can change it.
How do you set WP_MEMORY_LIMIT in wp-config.php?
Add the two define lines to wp-config.php above the "That's all, stop editing!" comment, then reload the failing page. Use this when PHP already has room but WordPress is still running at its 40M front-end default.
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
/* That's all, stop editing! Happy publishing. */
Position is not cosmetic. Everything below that comment runs after require_once ABSPATH . 'wp-settings.php';, by which point WordPress has already defined its default limits. A define placed there raises a "Constant WP_MEMORY_LIMIT already defined" warning and is ignored. If the file already contains the constant, change that line instead of adding a second one.
With WP-CLI on the server, one command does the same edit and anchors it in the right place:
wp config set WP_MEMORY_LIMIT 256M
wp config set WP_MAX_MEMORY_LIMIT 512M
Keep a copy of wp-config.php before editing by hand; a missing quote or semicolon gives a blank page, which the WordPress white screen guide helps you trace.
Should you use .user.ini or .htaccess to raise PHP memory?
Use .user.ini when PHP runs as PHP-FPM or CGI, which is the case on most current cPanel servers; use .htaccess only when PHP runs as an Apache module. Using the wrong one either does nothing or takes the site down.
| PHP handler | File in public_html | Line to add | Notes |
|---|---|---|---|
| PHP-FPM, CGI, LSAPI | .user.ini | memory_limit = 256M | Read again after user_ini.cache_ttl, 300 seconds by default |
| Apache mod_php | .htaccess | php_value memory_limit 256M | On FPM this line causes a 500 error on every page |
If the site returns 500 straight after an .htaccess edit, remove the line first and investigate second. If neither file changes what Site Health reports, the host's value overrides user files and a support request is the next step.
How do you find what is using the memory?
Start with the file path in the error, then measure peak memory per page with the Query Monitor plugin; a higher limit only buys time if the code keeps growing. Most cases trace to a backup, import, page builder or oversized image.
- Read the path: the folder under
wp-content/plugins/orthemes/is the first suspect; check it for an update. - Measure: Query Monitor shows peak memory use for each request in the admin bar.
- Halve the plugins: deactivate half, test, then split again; five rounds isolate one plugin among thirty.
- Check the error log: repeated entries at the same hour point to a cron job; the PHP error log guide shows where cPanel keeps it.
- Shrink uploads: WordPress makes several resized copies of each image, so a 6,000-pixel photo can exhaust memory on its own. Upload around 2,000 pixels wide.
What WordPress memory limit should you choose?
Choose the smallest value that clears the failing job: 256M suits most business sites, and 512M is for WooCommerce stores, LMS or membership sites with heavy admin reports. Setting 1G to make an error disappear hides a leak and lets one request crowd out others on shared resources.
| Site type | memory_limit | Heavy moments |
|---|---|---|
| Blog or brochure site | 128M–256M | Image resizing, security scans |
| WooCommerce with a page builder | 256M–512M | Checkout, product imports, builder templates |
| Membership or LMS | 512M | Bulk enrolments, report exports |
For a week after the change, check peak usage in Query Monitor. If ordinary pages sit near the new ceiling, the fix is in the code, and a WordPress speed optimisation review is more useful than another increase.
What if the host caps WordPress memory?
On WebJi® WordPress hosting the hosting panel exposes PHP's memory_limit, so you can raise it yourself without a ticket. If the value reverts or the field is locked, email support@webji.services with the domain, the figure Site Health shows and the full error line; support runs 24/7 in Hindi and English with an average first reply under 60 minutes. Stores that outgrow shared limits usually move to WooCommerce hosting, and the upload ceiling sits on the same screen, as explained in increasing the WordPress upload size.
Frequently asked questions
Why did my WP_MEMORY_LIMIT change have no effect?
Either the line sits below the "stop editing" comment, where WordPress has already set its defaults, or the host has locked PHP's memory_limit so ini_set cannot raise it. Move the line up first; if Site Health still shows the old value, raise memory_limit in the panel or ask the host.
How can I see the current WordPress memory limit?
In wp-admin open Tools › Site Health › Info. The Server section lists the PHP memory limit, and the WordPress Constants section lists WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. Together they show which value is binding.
Does a higher memory limit make WordPress faster?
No. The limit is a ceiling, not an allocation; a page that needs 60M uses 60M whether the limit is 256M or 1G. Speed comes from caching, fewer heavy plugins and a current PHP version. Raise the limit only to stop a fatal error.
Is it safe to set memory_limit to -1?
Not on a live site. A value of -1 removes the PHP limit entirely, so a runaway plugin can consume all the memory available to the account and stall every other request. Use a fixed value such as 256M or 512M instead.
Last editorial update: 14 November 2026.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.