504
5xx Server ErrorGateway Timeout
The server, acting as a gateway, didn't get a timely upstream response.
504 Gateway Timeout means a proxy or gateway waited for an upstream server and gave up before it answered. The upstream isn't necessarily down - it's just too slow, often because of a long query, a stuck external call, or an undersized timeout. It differs from 502, where the upstream replied but the reply was invalid.
About 5xx Server Error
The server failed to fulfill a valid request. The problem is on the server side, not the client.
How to fix 504 Gateway Timeout
- Find the slow upstream operation - a query, lock, or external call.
- Raise the proxy's upstream timeout if the work is legitimately long.
- Move long jobs to a background queue instead of the request path.
- Check upstream health and capacity under load.