HTTP 502 Bad Gateway
HTTP 502 Bad Gateway means a server acting as a gateway or proxy received an invalid response from an upstream server while fulfilling the request. A reverse proxy can also use 502 when it cannot obtain a usable response because the upstream closed the connection unexpectedly.
Identify the gateway that produced it
Placing a forward proxy in front of a site can leave several intermediaries on the route. TestMyProxies distinguishes Proxy refused the tunnel (HTTP 502) from Target returned HTTP 502. The former is the CONNECT response. The latter is a response from the target side.
Check upstream health and response handling
If you own the gateway, look up the failed request and check the upstream address, protocol and error log. Compare with a healthy upstream request. For a gateway that waits and then gives up, see 504 Gateway Timeout.
A 502 response after a successful CONNECT
In a trace, HTTP/1.1 200 Connection established can be followed by a second status, HTTP/2 502. The first line is the proxy accepting the tunnel. The second comes from the target side. If you operate that target, compare the reverse proxy’s upstream log with the application log for the same time and URL. A connection reset during response headers, a process restart, and a mismatch in the upstream protocol can all leave the reverse proxy without a usable HTTP response.
What to try before changing proxies
Run the default IP check, then request a small path on the affected target that you control. If the IP probe and the small target path work while one application route returns 502, report that route and its request ID. If the same proxy sends 502 at CONNECT for several previously working targets, check its service status or ask the provider to inspect its connection logs.