502Status code
5xxServer error
NoCacheable by default
RFC 9110 §15.6.3Defined in
Common causes
- App server crashed or is restarting behind nginx
- Upstream closed the connection
- Wrong upstream port
What to do
Check that the backend process is running and listening on the port the proxy expects.
Example response
HTTP/1.1 502 Bad Gateway
Content-Type: application/problem+json
{"status":502,"title":"Bad Gateway"}
Returning 502 in code
Express res.status(502).json({ … });
Flask return jsonify(…), 502
PHP http_response_code(502);
Go w.WriteHeader(502)
nginx return 502;