504
HTTPSERVER_ERRORCritical5xx Server ErrorHIGH confidence

Gateway Timeout

Production Risk

High. It means that user requests are not being completed. This points to a severe performance bottleneck or failure in the backend application.

What this means

The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server. This is similar to a 502, but the key difference is that the gateway timed out waiting, rather than receiving an invalid response.

Why it happens
  1. 1An upstream application server is processing a very slow, long-running query and does not respond before the gateway's timeout expires.
  2. 2The upstream server is overloaded and cannot process the request in time.
  3. 3A network issue between the gateway and the upstream server is causing extreme latency.
How to reproduce

A user requests a report that takes 2 minutes to generate, but the reverse proxy is configured with a 30-second timeout, so it gives up waiting.

trigger — this will error
trigger — this will error
GET /api/generate-report HTTP/1.1
Host: example.com

expected output

HTTP/1.1 504 Gateway Timeout

Fix 1

Increase Gateway Timeout

WHEN Legitimate requests are taking longer than the current timeout.

Increase Gateway Timeout
// Nginx example for proxy timeout
proxy_read_timeout 120s;

Why this works

Server Configuration

Fix 2

Optimize Upstream Performance

WHEN The upstream application is too slow.

Optimize Upstream Performance
Profile the application code, optimize database queries, or convert the long-running task to an asynchronous background job.

Why this works

Application Optimization

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors