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.
- Profile the origin: DB, cache, and external HTTP dependencies.
- Align timeouts: proxy ≤ origin worst-case with headroom.
- 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
Reduce latency or raise timeouts coherently
- Profile the origin: DB, cache, and external HTTP dependencies.
- Align timeouts: proxy ≤ origin worst-case with headroom.
- Add caching or async work for expensive operations.
Related
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.
Fix related issues
Still stuck? Try these related fixes next.
- Kubernetes CrashLoopBackOffThe container exits repeatedly—check logs, probes, and resource limits.
- Heroku H10 — app crashedThe web process exited; Heroku serves an error page. Logs show the real exception.
- Netlify — page not foundThe deploy exists but no asset matches the path—often SPA routing or a missing file in publish dir.
- Vercel — deployment not foundThe deployment URL or project alias does not exist or was removed.
- Cloudflare 525 — SSL handshake failedCloudflare could not complete TLS with your origin—cert mismatch, wrong port, or TLS version.
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
