502 Bad Gateway proxy errors: find out who sent it

Updated:

502 Bad Gateway means a server in the middle, which could be your proxy or the website's own front-end server, forwarded the request and did not get a valid answer back. Same number, two very different culprits, so before fixing anything work out who is returning the 502.

Private IPs, not shared with strangers

What a 502 from the proxy looks like

We made our test proxy answer 502 and recorded the responses, rewritten with 203.0.113.10:8080 and user123:pass456:

  • HTTPS site: curl -x http://user123:[email protected]:8080 https://example.com prints curl: (56) CONNECT tunnel failed, response 502.
  • Plain HTTP site: curl receives status 502.
  • Chrome loading an HTTPS page through that proxy reports ERR_TUNNEL_CONNECTION_FAILED and shows no 502 page at all.
  • The proxy checker shows HTTP 502; other codes appear the same way as HTTP <code>.

The tell: a 502 page on an HTTPS site

For HTTPS sites the proxy only opens a tunnel; it cannot insert its own page inside an encrypted connection. If the proxy refuses, Chrome reports ERR_TUNNEL_CONNECTION_FAILED. So when you see a full "502 Bad Gateway" page rendered on an https:// address, it almost certainly came from the website's server, not from the proxy.

Confirm by turning the proxy off and loading the same page. If it is still a 502, the website is having trouble and waiting or telling the site owner is all you can do.

When the proxy really is sending the 502

  • The destination does not answer the proxy. The site is down, overloaded, or refusing connections from the proxy's IP range.
  • A mistyped or unresolvable domain. The proxy cannot find the site's address, so there is nothing to forward to.
  • The destination port is closed. The request targets a port the site does not serve.
  • A temporary fault on the proxy side. Rarer; you notice it when every site returns 502 through one proxy but works through another.

What to do in each environment

  • Chrome or antidetect profiles: open a different large site in the same profile. If that loads, the proxy is fine and the original site is the problem.
  • Phones: switch off the Wi-Fi proxy and try the page over mobile data to see whether the site fails for everyone.
  • curl: add -v to see the 502 arrive right after CONNECT, then repeat with a different domain to narrow it down.
  • Python requests: for HTTP pages check response.status_code == 502 and retry after a pause; for HTTPS pages the failed tunnel is raised as requests.exceptions.ProxyError. Space retries out rather than hammering the site.

Step by step

  1. 1

    Note where the 502 appears

    A 502 page on an https address points to the website. A tunnel error in Chrome points to the proxy path.

  2. 2

    Turn the proxy off and reload

    A 502 without the proxy means the website itself is failing.

  3. 3

    Load another site through the same proxy

    If other sites work, the proxy is fine and only the original site is refusing or down.

  4. 4

    Check the proxy with the checker

    Paste the line into the proxy checker. If every site gives HTTP 502, open a ticket with the result.

Frequently asked questions

Does a 502 mean my proxy has expired?

Usually not. An expired or stopped proxy tends to produce a connection failure or a timeout; see proxy timeout.

Why does only one website return 502 through the proxy?

That site may be failing or not answering connections from the proxy's IP. Try later, or use an IP in another country.

What is the difference between 502 and 504?

A 502 means an invalid answer or none could be obtained; a 504 means the middle server waited too long. The checker shows both as HTTP <code>.

My scraper gets occasional 502s. Should I change proxies?

Scattered 502s usually mean an overloaded target. Slow your request rate and add spaced retries before swapping proxies; see proxies for web scraping.

Private IPs, not shared with strangers

VinaProxy private proxies help you avoid an IP being blocked because someone else was using it.

See pricing

Related articles

Proxy errors
Fixing ERR_TUNNEL_CONNECTION_FAILED with a proxy
ERR_TUNNEL_CONNECTION_FAILED means Chrome reached the proxy but no HTTPS tunnel opened. How to read the CONNECT code and fix it in Chrome, Puppeteer, Android.
Proxy errors
Proxy timeout errors: the connection hangs, then gives up
A proxy timeout means no answer arrived before the wait limit. Tell curl (28) and ERR_TIMED_OUT apart, tune Python timeouts and find where traffic is blocked.
Free tools
Proxy Checker: Check Your Proxies Online
Free proxy checker: paste up to 100 proxies as ip:port:user:pass and check proxy online for status, exit IP and latency. Learn what each error means.
Proxy setup
How to use a proxy with cURL (command-line syntax & debugging)
How to use curl with authenticated HTTP(S) proxies (-x http://user:pass@ip:port and -U) on Linux, macOS, and Windows.
Proxies by platform
Proxies for Web Scraping: unmetered dedicated IPv4 & ISP pools for 24/7 crawlers
High-speed HTTP(S) dedicated IPv4 and Static ISP proxies for Python, Playwright, Selenium, and Scrapy with unlimited monthly bandwidth.
Proxy setup
How to Configure Proxy in Google Chrome
Configure VinaProxy HTTP(S) proxies in Google Chrome without changing your whole OS IP using Chrome extensions, --proxy-server CLI flags, or separate user profiles.
Proxy setup
How to Configure Proxy on Windows 10 & Windows 11
Configure VinaProxy HTTP(S) proxies on Windows 10 and Windows 11 using WinINET System Settings, PowerShell Environment Variables, or netsh winhttp.
Proxy setup
How to set up a proxy in GenLogin (single profile & bulk import)
Configure HTTP ip:port:user:pass proxies in GenLogin antidetect browser. Sync timezone and WebRTC settings and troubleshoot profile connection errors.