502 Bad Gateway

HTTP 502 Bad Gateway is a 5xx server error status. A proxy or gateway got an invalid response from the upstream server.

502Status code
5xxServer error
NoCacheable by default
RFC 9110 §15.6.3Defined in

Common causes

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;

Other 5xx codes

Frequently asked questions

What does HTTP 502 mean?
A proxy or gateway got an invalid response from the upstream server.
Is 502 an error?
Yes. It is a server error: the request may be fine and the problem lies on the server or an upstream service.
Does a 502 hurt SEO?
If search engines see it repeatedly on pages that should rank, those pages can be dropped from the index. Fix it quickly.