PHP error guide

nginx upstream timed out: meaning and fix

Error summary

Fix the slow request or move long work to a worker before narrowly adjusting timeout. Nginx waits past fastcgi_read_timeout for FPM response headers.

What it means

Fix the slow request or move long work to a worker before narrowly adjusting timeout. Nginx waits past fastcgi_read_timeout for FPM response headers.

What the error means

This message means that nginx waits past fastcgi_read_timeout for FPM response headers. The exact signature distinguishes nginx upstream timed out from a generic application failure.

Why PHP produces it

The engine or service reports “nginx upstream timed out” because its required precondition was not met. Fix the slow request or move long work to a worker before narrowly adjusting timeout.

PHP version notes

The nginx upstream timed out wording here is based on Current PHP-FPM, Apache 2.4, or nginx; punctuation and exception class names can differ on older branches or vendor builds.

Most common causes

  • The immediate input or configuration reaches the specific condition: nginx waits past fastcgi_read_timeout for FPM response headers
  • The code path assumes the prerequisite for nginx upstream timed out has already been satisfied.
  • For nginx upstream timed out, development and production differ in version, extension, permissions, paths, or service configuration.
  • An earlier operation returned an unchecked value that is consumed by the line reporting nginx upstream timed out.

Minimal examples

BAD — reproduces the problem

nginx
fastcgi_read_timeout 1s;

FIXED — safer pattern

nginx
fastcgi_read_timeout 60s;

Step-by-step diagnosis

  1. Copy the complete “upstream timed out (110: Connection timed out) while reading response header from upstream” text and retain the first application stack frame.
  2. Reproduce nginx upstream timed out in the same SAPI and environment listed for this page.
  3. Before changing nginx upstream timed out, inspect the preceding value or directive and verify its type, path, version, and permissions.
  4. Apply the narrow correction—fix the slow request or move long work to a worker before narrowly adjusting timeout—then repeat the original request once.

Fixes

Correct the failing prerequisite

Fix the slow request or move long work to a worker before narrowly adjusting timeout

nginx
fastcgi_read_timeout 60s;

Fail explicitly at the boundary

Validate the condition before the operation that emits nginx upstream timed out, and log a safe diagnostic without credentials or full production paths.

Common mistakes when fixing it

  • Suppressing nginx upstream timed out instead of correcting its upstream condition.
  • Testing nginx upstream timed out only with the CLI binary when the failing request runs under FPM or Apache.
  • Changing a global setting for nginx upstream timed out before confirming the site-specific effective configuration.

How to prevent it

  • Add a focused test that exercises the boundary responsible for nginx upstream timed out.
  • Keep runtime versions, extensions, configuration, and deploy artifacts affecting nginx upstream timed out reproducible.
  • Validate external data and service return values before they can trigger nginx upstream timed out.

Web server / environment notes

fpm, nginx, linux. The failure occurs where nginx waits past fastcgi_read_timeout for FPM response headers

Tags: fpm,nginx,linux

Categories