504 Timeout ErrorWhat a 504 error means
Modern requests rarely go straight to the application. They pass through intermediaries — CDN edges, load balancers, reverse proxies like nginx, and sometimes your own forward proxy. A 504 is minted by one of those intermediaries when it forwarded your request to the next server in the chain and hit its own internal timeout before any response came back. Contrast that with a 502, where a response arrived but was invalid: with a 504, nothing arrived at all.
In the overwhelming majority of cases the slow party is the target's own backend: a database query that runs too long, an application server with a saturated worker pool, an API aggregating slow downstream calls, or an origin drowning under load. That means most 504s are target-side and transient — the same request often succeeds seconds later.
The important diagnostic detail is who served the error page. A branded CDN or load-balancer error page means the timeout fired inside the target's own infrastructure. A generic response from your forward proxy means the target never answered your proxy at all — a different problem with a different fix.