--- title: "504 Gateway Timeout — what it means and how to fix it" description: "A proxy or gateway waited for the server behind it and gave up before an answer arrived. What causes an HTTP 504, what to try as a visitor, and what to check if it is your own site." url: https://atoneplace.net/error/504/ site: "At One Place" --- # HTTP 504 — Gateway Timeout **HTTP 504: Gateway Timeout** A proxy or gateway waited for the server behind it and gave up before an answer arrived. ## What 504 actually means Like a 502, this comes from an intermediary reporting on the server behind it — but here the upstream was alive and simply too slow. The proxy hit its timeout and returned an error rather than waiting forever. That distinction matters when debugging: a 502 points at a process that is down or unreachable, a 504 points at one that is running but stuck, usually on a slow query, an external API call, or a lock. ## Common causes - A slow database query, often one missing an index - An external API call the application makes with no timeout of its own - A request doing too much work synchronously — a large report or export - A deadlock or lock contention holding the request open - The upstream saturated, so requests queue behind others - A proxy timeout set lower than the application's own worst-case response time ## If you're just trying to view the page 1. Wait and retry — a slow query or a busy period often clears 2. If it happens on one heavy action, such as generating a report, try a smaller date range or fewer items 3. Check the status page; a 504 across a whole site means the operators already know 4. Nothing on your side will speed the server up ## If it's your site 1. Find the slow operation before raising any timeout — a longer timeout turns a fast failure into a slow one 2. Check the database slow query log and add the missing index; this is the single most common root cause 3. Set explicit timeouts on every outbound HTTP call the application makes, so one slow dependency cannot consume a request slot indefinitely 4. Move long work to a background job and return 202 with a status URL instead of holding the connection 5. If you must raise the limit, raise `proxy_read_timeout` (Nginx) or the load balancer idle timeout — and remember the smallest timeout in the chain wins 6. Watch for cascading failures: one slow dependency can saturate the pool and turn into site-wide 504s ## Reference - **Status code:** 504 - **Reason phrase:** Gateway Timeout - **Category:** 5xx — Server Error - **Cacheable by default:** No - **Defined in:** RFC 9110 §15.6.5 ## Common questions ### What does HTTP 504 mean? A proxy or gateway waited for the server behind it and gave up before an answer arrived. Like a 502, this comes from an intermediary reporting on the server behind it — but here the upstream was alive and simply too slow. The proxy hit its timeout and returned an error rather than waiting forever. ### How do I fix a 504 error? Wait and retry — a slow query or a busy period often clears ### Is 504 a client error or a server error? 504 is in the 5xx range, which means server error. The request was acceptable but the server could not fulfil it, so retrying later can succeed. ## Related pages - [500 Internal Server Error](https://atoneplace.net/error/500/) - [502 Bad Gateway](https://atoneplace.net/error/502/) - [503 Service Unavailable](https://atoneplace.net/error/503/) - [524 A Timeout Occurred](https://atoneplace.net/error/524/) - [521 Web Server Is Down](https://atoneplace.net/error/521/) - [522 Connection Timed Out](https://atoneplace.net/error/522/) - [520 Web Server Returned an Unknown Error](https://atoneplace.net/error/520/) - [525 SSL Handshake Failed](https://atoneplace.net/error/525/) - [526 Invalid SSL Certificate](https://atoneplace.net/error/526/) - [530 Origin DNS Error](https://atoneplace.net/error/530/) - [501 Not Implemented](https://atoneplace.net/error/501/) - [511 Network Authentication Required](https://atoneplace.net/error/511/) ## Sources - Hypertext Transfer Protocol (HTTP) Status Code Registry — IANA (https://www.iana.org/assignments/http-status-codes/) - RFC 9110: HTTP Semantics — IETF (https://www.rfc-editor.org/rfc/rfc9110.html)