PHP Errors

Allowed Memory Size of 134217728 Bytes Exhausted: How to Fix It

By ErrorNest Published Updated 4 min read
134217728 bytes is a 128 MB PHP memory limit. Raise it to 256 MB in wp-config.php, your hosting panel or php.ini, then confirm the new limit is active.
Two DDR4 memory modules of 8 GB each
Photo: Bretwa, CC BY-SA 4.0, via Wikimedia Commons
On this page

The error Allowed memory size of 134217728 bytes exhausted means a PHP script tried to use more memory than PHP allows, so PHP stopped it. The number is the limit in bytes. 134217728 bytes is exactly 128 MB (128 × 1024 × 1024), which is PHP’s default memory limit and a common limit on shared hosting. A full message looks like this:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /home/user/public_html/wp-content/plugins/example/file.php on line 142

Quick fix: Raise the memory limit from 128 MB to 256 MB (steps 2 to 4), then confirm the new limit is active (step 6). If the error returns at 256 MB, read what to do when 268435456 bytes is exhausted.

What the error message tells you

  • Allowed memory size of 134217728 bytes is the limit that was in force: 128 MB.
  • tried to allocate N bytes is the last small request that pushed the script over the limit. It is usually small, so do not read it as the amount you need.
  • in /path/file.php on line N shows where PHP ran out. A path under wp-content/plugins/ or wp-content/themes/ names the plugin or theme that was running.

134217728 bytes in MB: the conversion

PHP counts memory in bytes, so the number in the error is easier to read once you convert it. Divide by 1024 to get kilobytes, and by 1024 again to get megabytes:

134217728 / 1024 = 131072 KB
131072 / 1024 = 128 MB

134217728 * 2 = 268435456 bytes = 256 MB
134217728 / 2 = 67108864 bytes = 64 MB

So 134217728 bytes is 128 MB. Doubling it gives 268435456 bytes (256 MB), which is the usual next step up and the value used in the fixes below.

1. Check the limit your site is using

In WordPress, open Tools > Site Health > Info > Server and look at PHP memory limit. If it shows 128M, PHP’s own limit is what you hit. Note this value so you can confirm later that a change worked.

2. Raise the limit in wp-config.php

Open wp-config.php in your host’s File Manager or over FTP and add this line above the comment that says to stop editing:

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

WordPress then asks PHP for 256 MB when it can. If your host fixes the limit at a lower value, this line has no effect, so continue with step 3.

Front view of a cluster of web servers in a data center
Photo: David Monniaux, CC BY-SA 3.0, via Wikimedia Commons

3. Raise the limit in your hosting control panel

Most hosts have a PHP settings page, often called PHP Configuration, PHP Options or MultiPHP INI Editor. Find memory_limit and set it to 256M, then save. Changes made here normally apply straight away.

4. Use php.ini or .user.ini

If you can edit your own PHP settings file, add or change this line:

memory_limit = 256M

Put it in php.ini if your host allows one, or in a .user.ini file in your site’s main folder. PHP re-reads .user.ini files about every five minutes by default, so wait a few minutes before testing.

5. Try .htaccess on Apache

On some Apache servers that run PHP as a module, you can add this line to .htaccess:

php_value memory_limit 256M

Warning: On servers that run PHP through PHP-FPM or CGI, this line causes a 500 error. If your site breaks after adding it, remove the line straight away.

6. Confirm the new limit is active

Reload Tools > Site Health > Info > Server and check that PHP memory limit now shows 256M. If it still shows 128M, your host is overriding your setting, so ask them to raise it or tell you the maximum your plan allows. If a new error appears with 268435456 bytes in it, the new limit took effect and something is still using more than 256 MB.

7. Find what pushes a site past 128 MB

A normal page does not need 128 MB. The usual triggers are:

  • A page builder, WooCommerce report or large plugin screen in the dashboard.
  • An import, export or backup running in one go.
  • Regenerating thumbnails or processing very large images.
  • A scheduled task running at the same time as a visitor request.

If the error appears only when you do one particular thing, that action is the cause. Deactivate the plugin named in the file path to test.

Frequently asked questions

Is 128 MB enough for WordPress?

Plain sites often run fine on 128 MB. Sites with page builders, WooCommerce or many plugins usually need 256 MB.

Does raising the limit slow my site down?

No. It is a ceiling, not an amount PHP reserves. A page uses only what it needs.

What is 134217728 divided by 1024?

It is 131072, which is the limit in kilobytes. Divide by 1024 once more and you get 128, the limit in megabytes.

What do the other numbers in this error mean?

They are limits written in bytes: 67108864 is 64 MB, 134217728 is 128 MB, 268435456 is 256 MB, 536870912 is 512 MB and 1073741824 is 1 GB. Our general guide to the allowed memory size error has a full table.

When to contact support

Contact your host if the limit will not change or if your plan caps it at 128 MB. If the site is down with a critical error message instead, see how to fix the WordPress critical error.

Official resources