504 Gateway Timeout: What It Means and How to Fix It
Appears on: All browsers. 504 Gateway Timeout means a proxy server or CDN forwarded your request to an upstream origin server, but the origin didn't respond within the configured time limit. The proxy gave up waiting. This is a server-side problem — the backend is too slow, overloaded, or unreachable.
What 504 Gateway Timeout actually means
When you visit a website, your browser typically talks to a proxy layer (Nginx, Cloudflare, AWS ALB) that forwards requests to an application backend. Each proxy has a proxy_read_timeout — if the backend doesn't respond within that window (commonly 60 seconds), the proxy returns 504 to the browser rather than waiting indefinitely. The backend may be running a slow database query, waiting on a third-party API, or simply crashed and not responding at all.
Most likely causes (ranked)
- Backend application performing a slow operation — heavy database query, large file processing, third-party API call
- Backend server overloaded — all workers busy, request queued until timeout
- Network partition between proxy and origin server — connectivity lost in the data center
- Origin server crashed — process died, no longer accepting connections
- Proxy timeout set too low for a legitimately long-running operation
What to try as a visitor
Step 1: Reload and retry
Press Ctrl+Shift+R after waiting a minute. Transient backend slowdowns from traffic spikes typically normalize quickly, and the 504 clears on the next request.
Step 2: Clear browser cache
Press Ctrl+Shift+Delete → Advanced → check Cached images and files → Clear data. Some browsers cache 504 responses; clearing ensures you're seeing the current server state.
Step 3: Check the site's status page
Visit downdetector.com or the site's own status page. If degraded performance is reported, the 504 is server-side and you can only wait for recovery.
Step 4: Try a different network
Switch to a mobile hotspot and reload. If the site works on a different network, there may be routing problems between your ISP and the server's data center — contact your ISP if this persists.
Step 5: For site operators — investigate the timeout chain
In Nginx, check and increase proxy_read_timeout if legitimate operations take longer than the current limit. Profile the slow backend code: use EXPLAIN ANALYZE on slow queries, add APM tracing to find long external API calls. Verify origin server resources aren't exhausted with top or htop.
Frequently Asked Questions
What is the difference between 504 and 502?
504 is silence — the upstream server didn't respond within the time limit. 502 is a bad answer — the upstream responded with invalid data or an error. Both originate from the proxy layer, but 504 means no response arrived and 502 means a bad response arrived.
Can a slow internet connection cause 504?
Rarely. In practice, 504 is almost always the backend server being too slow to generate a response — a heavy database query, a slow API, or resource exhaustion. Your internet connection speed has almost no bearing on whether a server responds within its timeout window.
Related Guides
502 Bad Gateway
When the upstream server returns a bad response instead of timing out.
503 Service Unavailable
When the server deliberately refuses due to overload or maintenance.
Cloudflare 522
Cloudflare's specific timeout error when the origin doesn't respond.
This Site Can't Be Reached
When no response arrives at all due to DNS or connectivity failure.