Fixing ERR_TUNNEL_CONNECTION_FAILED with a proxy

Updated:

To load an https:// page through a proxy, the browser sends a CONNECT request and waits for the proxy to open a tunnel to the site. ERR_TUNNEL_CONNECTION_FAILED appears when the proxy answers that request with an error instead of agreeing. The catch is that Chrome does not tell you which error, so the first job is finding the real code.

Proxies that work with Puppeteer and Playwright

Two cases we reproduced

Both ran against a test proxy, rewritten here with the documentation address 203.0.113.10:8080 and user123:pass456. In a normal Chrome window the 407 case does not become a tunnel error; Chrome opens a sign-in dialog for the proxy username and password instead. Tunnel errors caused by a 407 therefore show up mostly in automation tools and in apps that cannot prompt for a password.

Proxy answers CONNECT withChrome showscurl shows
407 with no way to enter a password (headless Chrome)ERR_TUNNEL_CONNECTION_FAILEDcurl: (56) CONNECT tunnel failed, response 407
502 because the proxy cannot reach the siteERR_TUNNEL_CONNECTION_FAILEDcurl: (56) CONNECT tunnel failed, response 502

Causes, most likely first

  • An automation script sends no credentials. Chrome's --proxy-server flag accepts host and port only, not user:pass. Headless Puppeteer or Selenium gets a 407 and reports a tunnel failure.
  • A phone app behind a password-protected Wi-Fi proxy. The app has no login dialog, so HTTPS breaks while the browser still works.
  • The proxy cannot reach the target. It returns 502 to CONNECT; the 502 Bad Gateway page covers this in depth.
  • Only some sites fail. The destination is blocking or down while other sites work through the same proxy.

Find the real code with one curl command

Run curl -v -x http://user123:[email protected]:8080 https://example.com with your own values. Look at the line right after > CONNECT example.com:443 HTTP/1.1: a 407 means following the 407 guide; a 502 points at the destination or the path behind the proxy. If you prefer not to use a terminal, paste the line into the proxy checker, which reports auth failed (407) or HTTP 502 for the same situations.

Fixes by environment

  • Puppeteer: keep --proxy-server=http://host:port at launch and call page.authenticate({ username, password }) before navigating. Full example in the Puppeteer proxy guide.
  • Playwright: pass proxy: { server, username, password } when launching the browser and Playwright answers the 407 for you; see Playwright.
  • Selenium: Chrome does not take user:pass on the command line; the Selenium guide shows workable options.
  • Chrome on Windows: if the sign-in dialog never appears, check whether a proxy extension is suppressing it, then retry in a window without extensions.
  • Phones: for apps that need an authenticated proxy, use a proxy app that supports user:pass as in the Android setup guide.

Step by step

  1. 1

    Identify the CONNECT response

    Run curl -v -x with your proxy line, or paste it into the checker, to learn whether the proxy returns 407 or 502.

  2. 2

    For 407: supply credentials properly

    In scripts, use the library's authentication hook instead of putting user:pass in --proxy-server.

  3. 3

    For 502: try another site

    Load a large site such as example.com through the same proxy. If it works, the original destination is the problem.

  4. 4

    Re-run and confirm the exit IP

    Once the tunnel opens, visit my IP in that same browser to confirm traffic goes through the proxy.

Frequently asked questions

Why do http pages load while https pages fail?

Plain http needs no CONNECT; the proxy forwards the request directly. Only https opens a tunnel, so tunnel errors only appear there.

What causes ERR_TUNNEL_CONNECTION_FAILED on Android?

Most often an app that cannot pass the username and password to a Wi-Fi proxy. Try the same page in Chrome for Android; if Chrome can prompt and load it, the app is the issue.

Can I put user:pass inside --proxy-server?

No. Chrome ignores credentials in that flag, which leads to a 407 and the tunnel error. Authenticate through Puppeteer, Playwright or an extension instead.

Will switching to SOCKS5 remove the tunnel error?

Only if your order is SOCKS5. VinaProxy offers both HTTP(S) and SOCKS5; choose the protocol your order shows in the dashboard, since a mismatch causes different errors.

Proxies that work with Puppeteer and Playwright

VinaProxy proxies use standard user:pass login that popular automation libraries handle out of the box.

See pricing

Related articles

Proxy errors
How to fix 407 Proxy Authentication Required
A 407 Proxy Authentication Required error means the proxy answered but rejected your login. See real curl output, the likely causes and fixes per app.
Proxy errors
502 Bad Gateway proxy errors: find out who sent it
A 502 Bad Gateway through a proxy means a middle server got no valid reply. How to tell whether the proxy or the website is at fault, with real curl output.
Proxy setup
How to set up an authenticated proxy in Puppeteer (Node.js)
Configure authenticated HTTP(S) proxies in Node.js Puppeteer using the --proxy-server launch flag and await page.authenticate().
Proxy setup
How to set up a proxy in Playwright (Browser & Per-Context Auth)
Configure authenticated HTTP(S) proxies in Playwright for Node.js and Python. Run multiple isolated static IPs across BrowserContexts.
Proxy setup
How to set up an authenticated proxy in Selenium WebDriver
Configure username:password authenticated HTTP(S) proxies in Selenium WebDriver using selenium-wire or a Chrome onAuthRequired extension.
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 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.