Behind ERR_TUNNEL_CONNECTION_FAILED: reading the proxy's CONNECT reply

Updated:

ERR_TUNNEL_CONNECTION_FAILED appears when Chrome asks a proxy to open a tunnel for an https:// page and the proxy says no. Chrome sends a CONNECT request, expects permission, and gets an error status instead. The difficulty is that Chrome hides that status, so your first task is to recover the actual code.

Built for automation scripts

Likely causes, ranked

  • A script launches Chrome without credentials. The --proxy-server flag carries host and port only; any user:pass you put there is dropped. Puppeteer or Selenium in headless mode then receives a 407 and reports it as a tunnel failure.
  • An app behind a Wi-Fi proxy that needs a password. Apps have no login prompt, so their HTTPS requests fail even though the phone's browser works.
  • The proxy cannot reach the destination. It answers the CONNECT with 502. The 502 Bad Gateway page goes deeper into that case.
  • Only certain sites fail. The destination is down or refusing, while the same proxy opens other sites without trouble.

What we saw in testing

We triggered both common cases on a test proxy, rewritten below as 203.0.113.10:8080 with the login user123:pass456. In each row Chrome displayed the same message, which is why it tells you so little on its own.

Proxy's reply to CONNECTChromecurl
407, and no way to type a password (headless Chrome)ERR_TUNNEL_CONNECTION_FAILEDcurl: (56) CONNECT tunnel failed, response 407
502, the proxy could not reach the siteERR_TUNNEL_CONNECTION_FAILEDcurl: (56) CONNECT tunnel failed, response 502

Recover the hidden status code

Run curl -v -x http://user123:[email protected]:8080 https://example.com with your own proxy values and read the reply that follows > CONNECT example.com:443 HTTP/1.1. A 407 sends you to the 407 guide. A 502 points at the destination or the route beyond the proxy.

Prefer not to open a terminal? The proxy checker reports the same two situations as auth failed (407) and HTTP 502.

Note that an ordinary, visible Chrome window handles a 407 differently: it shows a sign-in box for the proxy username and password instead of the tunnel error. That is why 407-driven tunnel errors mostly appear in automation and in apps that cannot prompt.

Fixes for each environment

  • Puppeteer: launch with --proxy-server=http://host:port, then call page.authenticate({ username, password }) before the first navigation. A full example is in the Puppeteer proxy guide.
  • Playwright: give proxy: { server, username, password } in the launch options; Playwright answers the 407 by itself. See Playwright setup.
  • Selenium: Chrome will not accept user:pass on its command line. The Selenium guide lists approaches that work.
  • Desktop Chrome on Windows: when the sign-in box never shows up, an extension may be blocking it. Try again in a window with extensions disabled.
  • Phones: apps that need an authenticated proxy work best through a proxy app that supports user:pass, as described in the Android setup guide.

Step by step

  1. 1

    Find out what the proxy answered

    Use curl -v -x with your proxy line, or the checker, to see whether the reply to CONNECT is 407 or 502.

  2. 2

    407: hand over credentials correctly

    In automation, use the library's authentication feature rather than placing user:pass inside --proxy-server.

  3. 3

    502: test a different destination

    Open a large, stable site such as example.com through the same proxy. If it loads, the original site is the problem.

  4. 4

    Confirm the exit IP

    When the tunnel opens, load my IP in that same browser to check traffic really leaves through the proxy.

Frequently asked questions

Why do http:// pages work while https:// pages fail?

Plain HTTP requests are forwarded directly and need no CONNECT. Only HTTPS asks for a tunnel, so a tunnel error can only happen on HTTPS pages.

What triggers ERR_TUNNEL_CONNECTION_FAILED on Android?

Usually an app that cannot send the username and password to a Wi-Fi proxy. Open the same page in Chrome for Android: if Chrome prompts and loads it, the app is what fails.

Can credentials go inside --proxy-server?

No. Chrome discards them, the proxy replies 407 and you get the tunnel error. Authenticate through Puppeteer, Playwright or an extension instead.

Which proxy type should I select to avoid this?

ProxyV4 proxies are HTTP(S) with username and password, so choose HTTP in your tool and supply the login through its authentication setting.

Built for automation scripts

ProxyV4 proxies use plain user:pass authentication that Puppeteer and Playwright accept without workarounds.

See live prices

Related articles

Proxy errors
Fixing a 407 from your proxy: a credentials checklist
407 Proxy Authentication Required means the proxy is reachable but refused your login. Read the curl trace, find the credential mistake and fix it per app.
Proxy errors
Who sent the 502? Diagnosing Bad Gateway behind a proxy
Seeing a 502 Bad Gateway through a proxy? Learn to tell a proxy-side 502 from a website-side one, read the curl and Chrome output, and fix it in each tool.
Proxy setup
Puppeteer with an authenticated proxy: launch flag plus login
Point Puppeteer at an HTTP(S) proxy with --proxy-server, log in with page.authenticate() on every tab, and run several IPs in one Chrome via browser contexts.
Proxy setup
Playwright proxy authentication, one static IP per context
Give each Playwright browser context its own authenticated HTTP(S) proxy in Node.js or Python, match timezone and locale to the IP and confirm the exit address.
Proxy setup
Selenium WebDriver and authenticated proxies: what works
Selenium proxy auth for ChromeDriver: why --proxy-server ignores user:pass, how selenium-wire or an onAuthRequired extension fixes it, and how to verify the IP.
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
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.