504Status code
5xxServer error
NoCacheable by default
RFC 9110 §15.6.5Defined in
Common causes
- Slow database query
- Long report generation
- Upstream server unreachable
What to do
Speed up the slow request, move it to a background job, or raise the proxy timeout.
Example response
HTTP/1.1 504 Gateway Timeout
Content-Type: application/problem+json
{"status":504,"title":"Gateway Timeout"}
Returning 504 in code
Express res.status(504).json({ … });
Flask return jsonify(…), 504
PHP http_response_code(504);
Go w.WriteHeader(504)
nginx return 504;