HTTP 504 Gateway Timeout โ Meaning, Causes & How to Fix
The server, acting as a gateway or proxy, did not get a response in time from the upstream server.
- Code
- 504
- Name
- Gateway Timeout
- Class
- 5xx Server Error
- Specification
- RFC 9110 ยง15.6.5
- Cacheable by default
- Only with explicit Cache-Control / Expires
What HTTP 504 means
504 Gateway Timeout is returned by a proxy, load balancer or CDN when the upstream server did not reply within its time limit. The upstream may still be working on the request, so the operation could have partly completed.
Common causes
- Slow database queries or long-running scripts.
- Upstream server overloaded or hung.
- Proxy timeouts set lower than the app needs (e.g. nginx
proxy_read_timeout, default 60 s). - A CDN timeout waiting for the origin.
How to fix it
For site owners
- Find the slow request in the app logs and optimise it (indexes, caching).
- Move long jobs to background workers and return 202.
- Raise proxy timeouts only as a last resort.
For visitors & developers
- Retry after a short wait โ but be careful repeating payments or orders, they may have gone through.
SEO impact
Timeouts count as server errors for Googlebot: they reduce crawling, and slow servers get crawled less. Persistent 504s can drop URLs from the index.
Example 504 response
HTTP/1.1 504 Gateway Timeout
Server: nginx
Content-Type: text/html
Related status codes
Check or look up another code
Search and filter every code in the HTTP Status Codes tool, browse the full list by class, or read HTTP status codes explained: the complete developer guide.
Open HTTP Status Codes tool โAll status codesFrequently asked questions
What does HTTP 504 mean?
HTTP 504 Gateway Timeout is a 5xx Server Error status code. The server, acting as a gateway or proxy, did not get a response in time from the upstream server.
What is the difference between 504 and 408?
504: a gateway gave up waiting for the upstream server. 408: the server gave up waiting for the client to send the request.
Which specification defines 504?
It is defined in RFC 9110 ยง15.6.5.
Is a 504 response cacheable?
Not by default. A 504 response is only stored by caches when it carries explicit freshness information such as Cache-Control: max-age or Expires.