Skip to content
Docs

Allowed memory size of 134217728 bytes exhausted

Raise PHP's memory_limit in your app's PHP settings, up to the app's memory limit. On a WordPress or PHP site it's "Memory per request".

Updated 17 Oct 20262 min read

The fix on Tanzahost: raise PHP's memory_limit for your app. It can go up to the app's own memory limit, never above it.

  • A deployed PHP app, like Laravel: open the app. Under PHP settings, set memory_limit, like 256M, and save. It applies from the next build: choose Save and build under Build and run.

  • A WordPress or PHP site: open the site. Under PHP settings, set Memory per request, like 256M, and save. The site restarts with it, without downtime.

If the value you want is more than the app may use, raise its memory limit first, under Limits. Limits cost nothing by themselves: the app pays only for the memory it really uses, hour by hour.

Why it happens

The number in the message is PHP's limit for one request or one command, in bytes: 134217728 bytes is 128 MB, 268435456 is 256 MB. When a page or a command needs more, PHP stops it with this error. On Tanzahost the starting values are:

Wherememory_limit until you change it
A deployed PHP app, like Laravel128 MB, PHP's own default
A WordPress or PHP siteHalf of the site's memory limit, and at least 64 MB

A site's starting value is half of its memory on purpose: one heavy page then fails alone, while the rest of the site keeps answering.

For a deployed app, you can also set it in tanzahost.json, in your code. The dashboard's value wins over the file:

json
{
  "php": {
    "ini": { "memory_limit": "256M" }
  }
}

A value above the app's memory limit is refused. For an app limited to 512 MB, the message is "memory_limit can be at most 512M." -1, no limit at all, is refused too.

How to check

  1. Read the line in the error: (tried to allocate 20480 bytes) is the last small piece PHP asked for, not the whole need. The page needed more than the limit in total.

  2. Look at the app's numbers. If its memory is already near its limit, raising memory_limit alone won't help: raise the limit under Limits too, or find what loads so much, like a report that reads a whole table at once.

  3. In the app's terminal, print the limit PHP really uses:

Terminal
php -r 'echo ini_get("memory_limit"), PHP_EOL;'