504 gateway timeout

A 504 Gateway Timeout is an HTTP status returned when a server does not receive a timely response from a dependency needed to complete a request. The API prefers returning a fast 504 when its dependency time budget expires rather than leaving the request hanging indefinitely.

Minimal example

go
if errors.Is(err, context.DeadlineExceeded) {
    http.Error(w, "gateway_timeout", http.StatusGatewayTimeout)
}

Learn this concept

Lesson 6.5 · Request-scoped logging and timeouts

Used in exercises

Exercise 6.6 · Request context and timeout layer