How to Increase the PHP Memory Limit in WordPress

If you’ve hit a message like “Allowed memory size of 41943040 bytes exhausted,” or a page has gone suddenly blank while you were installing a plugin or importing content, you need to increase the PHP memory limit in WordPress. It sounds intimidating, but the fix is usually one line in one file. This guide walks through the methods in order — easiest and safest first — and, just as importantly, explains when the limit isn’t yours to raise because it’s set by your host or your plan.

First, what’s actually happening: PHP is the code that runs WordPress, and it’s given a memory allowance — a ceiling on how much it can use to build a page. When a task needs more than that ceiling (a big import, a heavy plugin, a page builder), PHP stops and throws the memory error. Raising the ceiling fixes it, up to the point your server allows.

The signs you’ve hit the memory limit

  • A message mentioning “Allowed memory size of … bytes exhausted.”
  • A blank white page when you open or save a particular page — the white screen of death, which is very often a memory problem.
  • A large plugin, import, or backup that fails partway through.
  • The dashboard timing out or dying on a memory-heavy screen.

Method 1: Edit wp-config.php (try this first)

WordPress has its own memory setting you can raise without touching server files. Find wp-config.php (WordPress’s main settings file) in your site’s root folder, and just above the line that reads /* That's all, stop editing! Happy blogging. */, add:

define( 'WP_MEMORY_LIMIT', '256M' );

That raises the limit WordPress requests for the front end of your site. WordPress ships with a fairly conservative default (often around 40–64 MB), and 256M is a comfortable, common target that handles most plugins and imports.

The admin area sometimes needs more than the front end — for tasks like imports and updates — so you can also add:

define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Save the file and reload the page that was failing. For a lot of sites, that’s the whole fix. One caveat, which we’ll come back to: WordPress can only ask for this much — the server still has the final say.

Method 2: Edit php.ini (if wp-config didn’t stick)

If the WordPress setting didn’t help, the limit is being capped lower at the server level, in a file called php.ini. On hosting where you can edit it, find or add the line:

memory_limit = 256M

This raises PHP’s own ceiling for your whole site, which is the one WordPress’s request has to fit inside. On many shared hosts you won’t have access to this file — which is itself a useful signal, and we’ll get to what it means.

Method 3: Edit .htaccess (Apache servers)

If your site runs on Apache and you can’t reach php.ini, you can sometimes set the limit in the .htaccess file (a server settings file) in your site’s root. Add:

php_value memory_limit 256M

A word of care: .htaccess controls a lot of how your site behaves, and a small mistake here can take the whole site offline. Copy the file somewhere safe before you edit it, and if a change causes an error, restore the copy. Some servers don’t allow this method at all and will error — if that happens, remove the line.

When it’s not yours to raise: the host and plan ceiling

Here’s the part most tutorials skip. Every method above is you asking for more memory — but the server enforces a hard ceiling that your request cannot exceed. If your host caps PHP memory at, say, 128 MB for your plan, then adding 256M in wp-config.php does nothing; you’ll still hit the wall at 128.

You’ve run into a host or plan limit if:

  • You raised the limit in wp-config.php (and maybe .htaccess) and the error didn’t budge.
  • You have no access to php.ini and .htaccess changes are ignored or throw errors.
  • Your host’s plan documentation lists a fixed PHP memory allowance.

At that point your options are to ask your host to raise the ceiling (some will, some won’t), move to a higher plan, or move to hosting that gives WordPress the room it needs by default. This limit is especially common on cheap shared plans, and it’s one of the quiet ways a bargain host makes itself frustrating — you can see the fix but you’re not allowed to apply it.

Don’t just crank it to the maximum

It’s tempting to set the limit sky-high and move on, but a memory error is sometimes a symptom, not the disease. A single poorly-built plugin can leak memory and eat any ceiling you give it. If you find yourself raising the limit again and again, the real fix may be identifying the heavy plugin — the same detective work we describe for a slow WordPress site — rather than feeding it endless memory. A sensible ceiling (256M for most sites, more for busy stores) plus a tidy plugin list beats an enormous limit propping up a bad plugin.

The managed-hosting answer: sane defaults, no wrestling

On managed hosting, PHP memory is set to a generous default that suits real WordPress and WooCommerce workloads, so most people never see a memory error in the first place — and if a genuinely heavy task needs more, it’s a quick support request rather than a hunt through server files you may not have access to. Stores need more headroom than brochure sites, which is exactly why our WooCommerce plan is built for it; we lay out those needs in WooCommerce hosting requirements.

The broader point: on the right platform, the PHP memory limit is something the host has already handled, not a file you edit under pressure when a page goes blank. See what’s included, and the resources your site actually gets, on our hosting page.