Who sent the 502? Diagnosing Bad Gateway behind a proxy
Updated:
A 502 Bad Gateway through a proxy means some intermediate server passed your request on and got back nothing usable. That intermediate server may be your proxy, or it may be the website's own load balancer or CDN edge. The fix depends entirely on which one, so identify the sender before you change any settings.
Quick rule: an HTTPS page that shows a 502 came from the website
With an https:// address, a proxy only builds a tunnel; it has no way to place its own error page inside the encrypted connection. If the proxy cannot build that tunnel, Chrome shows ERR_TUNNEL_CONNECTION_FAILED, not a page. So a rendered "502 Bad Gateway" page on an HTTPS site was almost certainly produced by the site's own infrastructure.
To be sure, disable the proxy and open the same page directly. A 502 without the proxy means the website is struggling. Your options are to wait or to let the site owner know.
How a proxy-generated 502 shows up
We forced our test proxy to reply 502 and captured each client's reaction (address and login rewritten to 203.0.113.10:8080 and user123:pass456):
| Client | What it reports |
|---|---|
| curl, HTTPS target | curl -x http://user123:[email protected]:8080 https://example.com returns curl: (56) CONNECT tunnel failed, response 502 |
| curl, plain HTTP target | Status code 502 |
| Chrome, HTTPS page | ERR_TUNNEL_CONNECTION_FAILED, with no 502 page displayed |
| ProxyV4 proxy checker | HTTP 502 (any other status code is shown the same way, as HTTP <code>) |
Reasons a proxy returns 502
- The target never answers the proxy. The site is offline, overloaded, or turning away connections from the proxy's address range.
- The hostname cannot be resolved. A misspelled or non-existent domain leaves the proxy with nowhere to send the request.
- Nothing listens on the requested port. The request asks for a port the destination does not serve.
- A short-lived fault on the proxy. Less common. The sign is that every site returns 502 through one proxy while another proxy loads them normally.
Narrowing it down in your setup
- Chrome or an antidetect profile: open a different well-known site in that same profile. If it loads, the proxy is healthy and the first site is the one failing.
- Phone: remove the Wi-Fi proxy and load the page over mobile data. If it fails there as well, the site is down for everyone.
- curl: with
-vyou can watch the 502 come back straight after theCONNECTline. Repeat against another domain to see whether the problem follows the site or the proxy. - Python requests: for plain HTTP pages, test
response.status_code == 502and retry after a delay. For HTTPS pages the failed tunnel arrives asrequests.exceptions.ProxyError. Keep retries spaced out instead of firing them back to back. - Scrapers: if many sites succeed and one keeps returning 502, lower your request rate for that target; the web scraping page covers pacing.
Step by step
- 1
Look at the form of the error
A full 502 page on an https address points at the website. A tunnel error in Chrome points at the proxy path.
- 2
Load the page without the proxy
If the 502 is still there, the website itself is failing and the proxy is not involved.
- 3
Try a second site through the proxy
When other sites work, the proxy is fine and only the original destination is down or refusing.
- 4
Run the line through the checker
Paste it into the proxy checker. If every target gives
HTTP 502, send that result in a support ticket.
Frequently asked questions
Is a 502 a sign that my proxy has expired?
Rarely. An expired or stopped proxy normally gives a failed connection or a timeout instead. See proxy timeout for that case.
Why do I get a 502 on just one website?
That site is either having problems or not answering connections from the proxy's IP. Try again later or use an address in a different country.
502 versus 504: what is the difference?
A 502 means the middle server got an invalid reply or none it could use. A 504 means it gave up waiting. The checker displays both as HTTP <code>.
My scraper sees a 502 now and then. Do I need new proxies?
Occasional 502s usually point to a busy target rather than a bad proxy. Slow down and add retries with pauses before replacing anything.
An address only you use
A ProxyV4 private IPv4 is assigned to one customer for the whole rental, so another user's traffic cannot get it refused.
See live prices