← All HTTP status codes
5045xx — Server errors

HTTP 504 Gateway Timeout

A proxy in front of your app waited too long for an upstream response and gave up.

What it means

504 means "the gateway is up, but the thing behind it didn't respond fast enough." Different from 502 (upstream returned a bad response) — 504 means upstream returned nothing at all in the allowed time.

Almost always a slow dependency: a database query without an index, a third-party API that's degraded, a synchronous job that should have been async, or a CPU-bound request blocking the event loop. Look at upstream latency, then at the request that's timing out.

Common causes

  • Slow database query without an appropriate index
  • Synchronous call to a degraded third-party API
  • Long-running computation in a request handler
  • Origin connection pool starved
  • Misconfigured timeout chain (downstream timeout > upstream timeout)

How to fix it

  1. 1Add an index on the slow query — `EXPLAIN ANALYZE` finds the culprit
  2. 2Move long-running work to a background job and return immediately
  3. 3Set a per-request timeout shorter than the proxy's timeout
  4. 4Add caching for expensive read paths

How Uptimera reports 504

Uptimera flags 504 as down. Sustained 504s often correlate with traffic spikes — set up monitors on both your edge (response time) and your origin (latency) to spot the divergence early.

Catch 504s before your customers do

Uptimera monitors your URLs from multiple regions and alerts the moment a 504 starts firing. Free plan included.