Troubleshooting · Code 502

502 Bad Gateway Error When Using a Proxy

502 Bad Gateway means an intermediary server (gateway) received an invalid response or nothing at all from the upstream server. When using a proxy, the "intermediary" can be the proxy itself, but it is also very often the website's CDN or server. The first step is to identify which side returned the 502 code.

Author: Bùi Toàn · Updated: 19/11/2026

Who returned 502: the website or the proxy?

The 502 page shows the website's or Cloudflare's branding

For HTTPS sites, the proxy only forwards encrypted data and cannot inject an error page into the stream. If you see a 502 page with a Cloudflare logo, nginx, or the website's own styling, the issue is on the website's server. Try disabling the proxy: you will usually see the same 502 error.

The browser shows a generic error with no 502 page

For HTTPS sites, when the proxy fails to connect to the destination, Chrome typically shows ERR_TUNNEL_CONNECTION_FAILED instead of rendering a 502 error page.

curl -v shows 502 right after CONNECT

The line "< HTTP/1.1 502" immediately following the CONNECT command means the proxy returned 502: the proxy failed to establish a connection to the destination site.

When the proxy returns 502

  • The destination site cannot resolve its domain or rejects connections from the proxy's IP range.
  • The destination site closes the connection prematurely.
  • The destination port is blocked by the proxy's usage policy.
  • Temporary network issues between the proxy and the destination site.

What to do

  1. Open the same page on your regular connection without a proxy. If it still returns 502, wait for the website to resolve it.
  2. Through the proxy, open a different site (e.g., https://api.ipify.org). If this page loads, the proxy is working fine and the issue is specific to the target site.
  3. Run curl -v to see where the 502 originates.
  4. For automated scripts, retry after a few seconds with exponential backoff; 502 errors are often temporary.
  5. If all websites return 502 through the proxy for several minutes, contact ONET support with the proxy IP, destination URL, and the timestamp of the error.

Quick test

Test the proxy independently of your browser with a single command: curl -v -x http://IP:PORT -U user:pass https://api.ipify.org (on Windows PowerShell, type curl.exe). If the output prints the proxy IP, the proxy is working properly; the issue lies in how your device or software is configured to use it.

Need proxies? Buy dedicated proxies with automatic activation

Dedicated IPv4 proxies in 9 countries from 20.000₫/IP/month when buying from 2.000 IPs (39.000₫ for 1 IP) and Vietnam, US static ISP proxies. HTTP(S) and SOCKS5 with username and password, unlimited bandwidth, automatically provisioned after payment. Vietnam proxies currently support HTTP(S) only, with no SOCKS5 yet.

Buy Proxies Now

Frequently Asked Questions

Is a 502 error caused by an expired proxy?+

Usually not. An expired proxy will report a connection refusal or authentication error, not a 502.

Accessible without the proxy, but gives 502 when proxy is on?+

The website may be blocking or returning errors for the proxy's IP range, or connections from the proxy's country might be temporarily failing. Try a proxy from another country or a static ISP proxy.