HTTP 504 Gateway Timeout

A gateway’s timer runs while its connected upstream server stays silent

HTTP 504 Gateway Timeout means a server acting as a gateway or proxy did not receive a timely response from the upstream it needed. The gateway returned a status to the client. The upstream operation may still be running or may already have completed.

Find the timer that expired

Compare the failure time with the reverse proxy’s upstream deadlines and the application’s processing time. A slow database query, waiting for backend capacity or a delay reading the upstream response can put the request over the limit. Check which phase the gateway logged.

Distinguish the tester deadline

Target request timed out can appear when the tester gives up first. Target returned HTTP 504 records a response from the target side. If a write may have reached the backend, check its result or use the application’s documented idempotency mechanism before retrying.

Find the slow phase in an upstream trace

Suppose a reverse proxy consistently logs 504 at 30 seconds and its application records the first response bytes at 35 seconds. The timing supports a gateway response deadline and points to the application work before the response. In another incident the gateway might log that it never opened the upstream connection. That points to backend availability or connectivity. Check whether the deadline was for connecting, sending the request, waiting for the first bytes, or reading the response.

Compare a fast request with the slow one

Use a benign request to the same host through the same path, for example a small static file or read-only status route. If it succeeds quickly and a report fails, review the report’s processing time and its backing service. A background export or paginated endpoint can fit the gateway’s normal deadlines better than a single long request.

RFC 9110.

All HTTP status codes · All proxy testing guides · Open the proxy tester