504 Gateway Timeout
Web/HTTP
High severity
HTTP 504 — Gateway Timeout
The proxy waited too long for the upstream server to respond and gave up. Usually a slow query, a slow external call, or an overloaded backend.
Last reviewed 2026-08-29 by the Tech Issue Guide team.
Symptoms
- “504 Gateway Timeout” after a long pause on one specific page or report.
- It worsens as data grows or under load.
- Fast pages are fine; one heavy endpoint times out.
What causes 504 Gateway Timeout
- A slow database query or missing index on a large table.
- A blocking call to a slow third-party API with no timeout.
- The backend is overloaded and cannot get to the request in time.
- Proxy read/send timeouts set lower than the real work takes.
How to fix it — 3 steps
- Profile the slow endpoint — log query times and external-call durations to find what exceeds the timeout.
- As a stopgap, raise the proxy read/send timeout (e.g. proxy_read_timeout) so the page can complete while you fix the root cause.
- Add database indexes, cache expensive results, or move long work to a background job so the request returns quickly.
Terminal / CLI command
time curl -s -o /dev/null "https://example.com/slow-endpoint"
Shows how long the endpoint actually takes, so you can compare it to the proxy timeout.
How to confirm the fix: The endpoint responds well within the timeout, both cold and under normal load.
Prevent it from coming back
Set sane timeouts on every outbound call, index queries as data grows, and push slow tasks to a queue.
Frequently asked questions
Is raising the timeout a real fix?
Only a temporary one. It stops the 504 but users still wait. The lasting fix is making the endpoint fast — indexes, caching, or async processing.