Written from live project work
How to Increase the WordPress Memory Limit (Tested on 7.1)

If WordPress shows a white screen, a “critical error” notice, or a line like Allowed memory size of 41943040 bytes exhausted, the site ran out of PHP memory partway through building a page. You can increase the WordPress memory limit in a few minutes. The catch is that the usual fix, one line in wp-config.php, only works when your host lets WordPress raise the limit, and most guides skip how to tell. I tested each method on a local WordPress 7.1 install, so below you’ll see what actually happened, not just what should happen.
What is the WordPress memory limit?
The WordPress memory limit is how much server memory PHP may use to build one page. Two settings decide it, and mixing them up is the root of most failed fixes.
- PHP’s
memory_limitis set by your host inphp.ini. It is the real ceiling for every request. WP_MEMORY_LIMITis what WordPress asks for on normal pages. If you do not set it, WordPress uses 40M on a single site and 64M on multisite.WP_MAX_MEMORY_LIMITis what WordPress asks for on admin screens and heavy tasks such as image processing. It defaults to 256M.
The rule that matters is in WordPress core’s default-constants.php: WordPress only calls PHP to raise the limit when its own value is higher than the current one, and only when the host allows the value to change. If the host has locked memory_limit, WordPress quietly adopts the host’s number instead. So you can write 512M in wp-config and still run at 128M. Hosts often start low as well: cPanel sets PHP’s default limit from server memory, 32M on a 1 GB server, 64M on 2 to 4 GB and 128M above 4 GB.
How do I check my WordPress memory limit?
Go to Tools > Site Health > Info in the WordPress admin.
- Open Server and read PHP memory limit. When it differs on admin screens, WordPress shows a second line, PHP memory limit (only for admin screens).
- Open WordPress Constants and read WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.
One trap for developers: do not check it with WP-CLI. When I ran wp eval against my test site, PHP reported a memory limit of -1, meaning unlimited, because WP-CLI lifts the limit for its own commands. A web request on the same site, with the host set to 128M, reported 128M before WordPress loaded. Always check through the browser or Site Health.
How to increase the WordPress memory limit
To increase the WordPress memory limit, add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php. If Site Health does not change, raise PHP’s memory_limit in your hosting panel, php.ini or .user.ini, or ask your host. Take a backup or download a copy of any file before you edit it.
1. Edit wp-config.php
Open wp-config.php in your site’s root folder through your host’s file manager or SFTP. Add these lines above the line that says /* That's all, stop editing! Happy publishing. */:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
The first line covers normal pages and the second covers the admin. Placement matters: the last line of wp-config.php loads WordPress itself, so anything added after it runs too late to change the limit. Keeping new lines above the “stop editing” comment avoids that. Save the file, then check Site Health again.
2. Raise PHP’s limit in your hosting panel
If Site Health still shows the old number, the host’s PHP limit is the ceiling. Many hosts let you change it without touching files. On Hostinger, open hPanel, go to Advanced > PHP Configuration > PHP Options and pick a higher memory_limit, up to your plan’s fixed maximum. On cPanel hosts, open Software > MultiPHP INI Editor, pick your domain and set memory_limit to 256M. SiteGround is the exception to know about: its knowledge base says memory_limit cannot be changed on shared plans, and only its Cloud plans can have it raised through support. If you are choosing a host, my Hostinger vs SiteGround comparison covers what each one lets you change.
3. Edit php.ini or .user.ini
On hosts that allow a custom PHP file, add this line to php.ini or .user.ini in the site root:
memory_limit = 256M
Changes in .user.ini can take up to five minutes to apply, because PHP rereads that file every 300 seconds by default. On a local install, edit the main php.ini instead. On my Windows machine with XAMPP, that file is C:\xampp\php\php.ini, and the change applies after you restart Apache.
4. Edit .htaccess (Apache only)
Some guides suggest adding php_value memory_limit 256M to .htaccess. That line only works where PHP runs as an Apache module. On servers that run PHP another way it can cause a 500 error, so remove it straight away if the site breaks after you add it.
5. Ask your host
If none of this changes the number in Site Health, your plan has a fixed ceiling. Ask support to raise memory_limit for your site, or ask what the plan’s maximum is. If the answer is lower than your site needs, that is a sign to move to a bigger plan, or to hand the server side to someone through a WordPress maintenance service.
Why doesn’t WP_MEMORY_LIMIT work?
Usually because the host has locked PHP’s limit, so WordPress cannot raise it. To see what happens when you try to increase the WordPress memory limit, I ran the same WordPress 7.1 site through PHP’s built-in web server with different host limits, then read the limit back on a live page request. It runs UpdraftPlus and a few other common plugins.
| Setup | What WordPress did | Limit at the end of the request | Result |
|---|---|---|---|
| Host limit 128M, nothing in wp-config | Kept 128M, since its 40M default is lower | 256M, raised later by UpdraftPlus | Page loaded |
| Host limit 32M, nothing in wp-config | Raised it to its 40M default | 40M, crashed before plugins finished | Fatal error: Allowed memory size of 41943040 bytes exhausted, thrown inside UpdraftPlus |
Host limit 128M, WP_MEMORY_LIMIT set to 256M |
Raised it to 256M | 256M | Page loaded |
Two lessons came out of it. First, the 40M default is not enough for a real site with a few plugins. The crash happened even though WordPress had already raised the limit as far as its default allowed. Second, the file in the error message is just where memory ran out, not necessarily the cause. UpdraftPlus happened to be loading when the 40M was used up. Plugins also change the limit themselves: UpdraftPlus 1.26.8 raises it to WP_MAX_MEMORY_LIMIT on every request when less than 192M is available, which is why the first setup ended the request at 256M even though WordPress itself kept 128M.
What should the WordPress memory limit be?
In my experience, 256M is the right setting for most business sites, and 512M for stores and page-builder sites that do heavy admin work.
- Elementor: Elementor’s system requirements list 256M as the minimum, 512M as recommended and 768M for best performance. They add that sites running other demanding plugins such as WooCommerce may need 512M.
- WooCommerce: WooCommerce’s own guide to increasing the limit uses
define('WP_MEMORY_LIMIT', '256M');as its example. - Brochure sites: from what I see on client sites, 128M to 256M is usually plenty.
Do not just set 2048M and move on. The limit applies to each request, so a high number lets one runaway plugin eat server memory meant for other visitors. If a site keeps hitting 256M, something is wrong, and that is worth finding.
When raising the limit is not the fix
A memory error that comes back after you raise the limit usually points to a plugin, a theme function or an import that loads far too much at once. Common causes I see on client sites are huge product imports, a page builder rendering hundreds of widgets on one page, and backup or security plugins scanning the whole site in a single request.
To find it, turn on WP_DEBUG_LOG, reproduce the error and read wp-content/debug.log. Then deactivate plugins one at a time on a staging copy until the error stops. If the site is slow as well as crashing, my guide to speeding up a WordPress site covers the next steps. If you would rather hand it off, this is the kind of fix my WordPress speed optimization work starts with, and it is part of what a good WordPress maintenance plan should catch early.
Frequently asked questions
How do I increase the WordPress memory limit?
Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above the “stop editing” line, then check Tools > Site Health > Info. If the number does not change, raise PHP’s memory_limit in your hosting panel or ask your host, because the host’s limit is the ceiling.
What is the 40MB memory limit in WordPress?
The error “Allowed memory size of 41943040 bytes exhausted” means PHP hit a 40 MB limit, because 41,943,040 bytes is exactly 40 MB, and 40M is WordPress’s default WP_MEMORY_LIMIT for a single site (64M on multisite). WordPress only applies it when PHP’s own limit is lower. Most real sites need more, and in my test a site held to 40M crashed with a fatal memory error.
Where does WordPress show the memory limit?
Go to Tools > Site Health > Info. Under Server, read PHP memory limit. Under WordPress Constants, read WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. Don’t rely on WP-CLI for this, because it lifts PHP’s memory limit to unlimited for its own commands.
How do I increase the memory limit for Elementor?
Use the same wp-config.php line with 256M or more. Elementor lists 256M as its minimum and 512M as recommended. Make sure PHP’s memory_limit on your host is at least as high, or the setting will not take effect.
How do I increase the memory limit on localhost?
Edit your local PHP’s php.ini and set memory_limit to 256M or 512M, then restart the web server. In XAMPP on Windows the file is usually C:\xampp\php\php.ini. Other local tools keep their own php.ini, so check that tool’s documentation for where it lives.
Sources
WordPress core, wp-includes/default-constants.php and wp-admin/includes/class-wp-debug-data.php, version 7.1.2, read 2026-10-08. Reference: developer.wordpress.org, Editing wp-config.php.
Hostinger, What is PHP memory limit at Hostinger and the hPanel PHP Options guide; SiteGround, How to increase PHP Memory, retrieved 2026-10-08: hostinger.com, siteground.com.
PHP Manual, .user.ini files (user_ini.cache_ttl default 300 seconds) and How to change configuration settings, php.net.
Elementor, System requirements, updated 2026-08-24, elementor.com/help/requirements.
WooCommerce, Increasing the WordPress memory limit, updated 2026-06-22, woocommerce.com.
cPanel, MultiPHP INI Editor for WHM, default memory_limit values, docs.cpanel.net.
Tests on a local WordPress 7.1.2 install with PHP 8.2.12, UpdraftPlus 1.26.8 active, by Mohammad Humza, 2026-10-08.
Share this article


