Error fix

How to fix “504 Gateway Timeout

A proxy waited too long for an upstream response—slow database, cold starts, or network latency.

Updated Apr 20, 2026

Tools that help with this

Fastest fix

Start here first. Step 1 fixes most cases—then work down the list.

  1. Profile the origin: DB, cache, and external HTTP dependencies.
  2. Align timeouts: proxy ≤ origin worst-case with headroom.
  3. Add caching or async work for expensive operations.

Why this works

These steps work because it removes the most common source of mid-request resets: VPN/proxy interference, and it clears stale cached state that can cause the same request to fail repeatedly.

What this means

The edge server did not receive a timely response from the next hop. The client sees 504 instead of hanging forever.

Common causes

  • Slow upstream

    Heavy queries, N+1 API calls, or cross-region latency.

  • Timeout mismatch

    App timeout longer than proxy timeout, so the proxy gives up first.

Step-by-step fix

  1. Reduce latency or raise timeouts coherently

    1. Profile the origin: DB, cache, and external HTTP dependencies.
    2. Align timeouts: proxy ≤ origin worst-case with headroom.
    3. Add caching or async work for expensive operations.

Also see: 504 — browse the HTTP status hub.

FAQ

504 during traffic spikes?
Scale workers and optimize hot paths; avoid synchronous fan-out.
504 after deploy?
Health checks may pass while dependencies warm—watch cold start metrics.
Only POST 504?
Writes may hit slower storage—check locks and replication lag.

Still stuck? Try these related fixes next.

Edit your error

Tweak the message and run again—we'll match an existing fix or generate a new page.

Original error message
504 Gateway Timeout
Fix another errorHTTP status codesURL status checkerRedirect checkerAll tools
404Buddy - 504 Gateway Timeout – How to fix