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.

An address only you use

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):

ClientWhat it reports
curl, HTTPS targetcurl -x http://user123:[email protected]:8080 https://example.com returns curl: (56) CONNECT tunnel failed, response 502
curl, plain HTTP targetStatus code 502
Chrome, HTTPS pageERR_TUNNEL_CONNECTION_FAILED, with no 502 page displayed
ProxyV4 proxy checkerHTTP 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 -v you can watch the 502 come back straight after the CONNECT line. 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 == 502 and retry after a delay. For HTTPS pages the failed tunnel arrives as requests.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. 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. 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. 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. 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

Related articles

Proxy errors
Behind ERR_TUNNEL_CONNECTION_FAILED: reading the proxy's CONNECT reply
ERR_TUNNEL_CONNECTION_FAILED hides the proxy's real reply to CONNECT. Uncover the 407 or 502 behind it and fix Chrome, Puppeteer, Playwright or Android setups.
Proxy errors
When a proxy goes silent: diagnosing timeouts step by step
A proxy timeout means no reply came back before the limit. Read curl (28) and ERR_TIMED_OUT, set sensible Python timeouts and locate where packets get dropped.
Free tools
Check proxies in bulk: status, exit IP and latency
Free online proxy checker: paste up to 100 ip:port:user:pass lines and see which proxies work, their exit IP and latency, plus what each failure result means.
Proxy setup
Using cURL with an authenticated proxy: commands that prove it works
Send cURL requests through an authenticated HTTP(S) proxy with -x and -U, confirm the exit IP, read the CONNECT handshake and time each request on any OS.
Proxies by platform
Proxies for web scraping: a fixed pool of IPs with unmetered traffic
Web scraping proxies for Python, Scrapy, Playwright and Selenium: a pool of private IPv4 and static ISP addresses, unlimited bandwidth, flat per-IP pricing.
Proxy setup
Routing Google Chrome Through a Private Proxy
Put an HTTP(S) proxy on Google Chrome only, not the whole computer: a per-profile extension, a --proxy-server launch shortcut, or the system proxy settings.
Proxy setup
Setting a Proxy on Windows 10 and Windows 11
Set an HTTP(S) proxy on Windows 10 or 11: the Proxy page in Settings, saving the login in Credential Manager, variables for CLI tools and netsh winhttp.
Proxy setup
Setting up a GenLogin proxy so the IP and fingerprint tell one story
Add a GenLogin proxy to a browser profile, fill WebRTC and timezone from the IP, import lines through Proxy Manager, and fix 407 or timeout check errors.