HTTP

504 Gateway Timeout

A proxy waited for the upstream server but it didn't respond in time.

What it looks like

504 Gateway Time-out
nginx

[error] upstream timed out (110: Connection timed out) while reading response header from upstream

What does "504 Gateway Timeout" mean?

Returned by a proxy or load balancer when the app behind it took longer than the proxy’s timeout (often 60 seconds). The app may still be working on the request — the proxy has simply stopped waiting.

What causes "504 Gateway Timeout"?

  • A slow query or long-running request.
  • Upstream is hung or overloaded.
  • Proxy timeout set too low.

How do I confirm the cause?

  1. Time the same request directly against the app, bypassing the proxy, to see how long it really takes.
  2. Check slow-query logs and application traces for the endpoint to find which step is slow.
  3. Compare the proxy timeout (proxy_read_timeout in nginx, the idle timeout on cloud load balancers) with the app’s own timeout.

How do I fix "504 Gateway Timeout"?

  • Profile and speed up the slow endpoint/query.
  • Raise the proxy/app timeout if the work is legitimately long.
  • Move long work to a background job.

How do I stop it happening again?

  • Move long jobs — exports, reports, imports — to a background queue and let the page poll for the result.
  • Add database indexes for the queries behind slow endpoints, and keep proxy and app timeouts deliberately aligned.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors