Risposta rapida
Cosa significa ERR_TUNNEL_CONNECTION_FAILED con un proxy?
net::ERR_TUNNEL_CONNECTION_FAILED significa che Chrome ha chiesto al proxy di aprire un tunnel verso un sito HTTPS e il proxy non ha risposto 200 Connection established. Il browser nasconde lo stato reale. Con proxy residenziali CrawlRelay, la causa è generalmente credenziali mancanti in Playwright o Puppeteer, poi un target che il gateway non può raggiungere. Riproduci con curl -v per vedere il codice reale.
ERR_TUNNEL_CONNECTION_FAILED a colpo d'occhio
| Errore | ERR_TUNNEL_CONNECTION_FAILED |
|---|---|
| Tipo | Errore di rete Chromium |
| Inviato da | Il tuo browser, dopo che il proxy ha rifiutato o fallito la richiesta CONNECT |
| Definito in | CONNECT method: RFC 9110, section 9.3.6 |
| Riprovarlo? | Solo dopo scopri lo stato reale |
| Prima verifica | Riproduci con curl -v per vedere lo stato reale del CONNECT |
Cosa significa ERR_TUNNEL_CONNECTION_FAILED?
Per caricare una pagina HTTPS tramite un proxy HTTP, il browser prima invia CONNECT host:443. Se il proxy risponde 200, il browser inizia TLS dentro il tunnel. Qualsiasi altra risposta, tipo 407, 403 o 502, interrompe il tentativo e Chromium mostra un errore generico.
Ecco perché questo errore dice dove è fallito il tentativo, il tunnel, ma non il perché. Il perché è il codice stato che il proxy ha inviato, che puoi vedere con curl.
Com'è ERR_TUNNEL_CONNECTION_FAILED in Python, curl, Node.js e browser?
Lo stesso errore si presenta in modo diverso in ogni strumento. Questi sono i messaggi da cercare nei log:
- Playwright:
page.goto: net::ERR_TUNNEL_CONNECTION_FAILED at https://... - Puppeteer:
Error: net::ERR_TUNNEL_CONNECTION_FAILED at https://... - Barra degli indirizzi di Chrome: 'Impossibile raggiungere questo sito' con il codice
ERR_TUNNEL_CONNECTION_FAILED - Selenium con Chrome: lo stesso codice all'interno di un
WebDriverException
Cosa causa ERR_TUNNEL_CONNECTION_FAILED?
Probabilmente prima:
- Nessuna credenziale inviata (407 nascosto). Chrome ignora nome utente e password all'interno di
--proxy-server. - Una destinazione rifiutata (403 nascosto), come una categoria bloccata dalla policy di utilizzo del proxy.
- Una destinazione irraggiungibile (502 o 504 nascosto): un host morto, un errore di battitura o un fallimento DNS in uscita.
- Una porta sbagliata: puntare il browser sulla porta SOCKS5 come se fosse HTTP, o viceversa.
Come diagnostico ERR_TUNNEL_CONNECTION_FAILED passo dopo passo?
- Esegui la stessa URL con curl usando
-v(comando qui sotto) e leggi la linea dopoCONNECT. - Un
407indica le credenziali; un403una destinazione rifiutata; un502o504il target o l'uscita. - Conferma che il browser usi la porta HTTP per un server proxy
http://. - Testa una pagina semplice come
https://api.ipify.orgprima del tuo vero target.
# Use the URL that fails; with https://api.ipify.org instead, you test the gateway alone.
# "HTTP/1.1 200 Connection established" first, then the site's own status: the site answered.
curl -v -x http://USERNAME:[email protected]:7777 https://TARGET_URL
# Same test through the SOCKS5 port, with DNS resolved at the exit
curl -v --socks5-hostname gw.crawlrelay.com:7778 --proxy-user USERNAME:PASSWORD https://TARGET_URLCome risolvo ERR_TUNNEL_CONNECTION_FAILED?
- Playwright: passa
server,usernameepasswordnell’opzioneproxy, per browser o contesto. Vedi la guida Playwright. - Puppeteer: lancia con
--proxy-server=http://host:porte chiamapage.authenticate()prima del primogoto. Vedi la guida Puppeteer. - Selenium: esegui un piccolo forwarder locale che aggiunge le credenziali. Vedi la guida Selenium.
- Controlla la destinazione rispetto alla nostra Acceptable Use Policy.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(proxy={
"server": "http://gw.crawlrelay.com:7777",
"username": "USERNAME-country-us",
"password": "PASSWORD",
})
page = browser.new_page()
response = page.goto("https://api.ipify.org")
print(response.status, page.inner_text("body"))
browser.close()Devo riprovare dopo ERR_TUNNEL_CONNECTION_FAILED?
Riprova solo quando conosci lo status nascosto. Un 407 o 403 nascosto si ripete all’infinito; correggi la configurazione. Un 502 o 504 nascosto può essere ritentato su una nuova uscita, come qualsiasi errore di gateway.
Come si applica ERR_TUNNEL_CONNECTION_FAILED a CrawlRelay?
La porta HTTP di CrawlRelay trasporta HTTPS tramite tunnel CONNECT, supportati da tutti gli strumenti basati su Chromium. Usa la porta HTTP per i browser: Chromium non supporta SOCKS5 con nome utente e password.
Gateway: gw.crawlrelay.com, porta 7777 (HTTP, HTTPS tramite CONNECT) e porta 7778 (SOCKS5). Formato username: USERNAME-country-{cc}-state-{state}-city-{city}-zip-{zip}-asn-{asn}-session-{id}-ttl-{minutes}. Correlato: 407 Proxy Authentication Required · ERR_PROXY_CONNECTION_FAILED · Guida Playwright.
ERR_TUNNEL_CONNECTION_FAILED: domande frequenti dagli sviluppatori
Perché curl funziona ma Playwright mostra ERR_TUNNEL_CONNECTION_FAILED?
Perché curl invia le credenziali dall’URL del proxy, mentre Chromium ignora le credenziali scritte nell’indirizzo del server proxy. In Playwright, passa username e password come campi separati dell’opzione proxy. In Puppeteer, chiama page.authenticate() prima della navigazione.
Posso usare proxy SOCKS5 con autenticazione su Chrome?
Non direttamente. Chromium supporta i proxy SOCKS5 ma non l’autenticazione con nome utente e password SOCKS5. Usa invece la porta HTTP del gateway, che gestisce siti HTTPS con tunnel CONNECT, o esegui un forwarder locale che autentica per il browser.
ERR_TUNNEL_CONNECTION_FAILED è causato dal sito web?
Raramente direttamente. Il tunnel è tra il browser e il proxy, quindi l’errore avviene prima che il sito veda un handshake TLS. Il sito può essere la causa indiretta se è irraggiungibile e il proxy risponde 502 o 504 alla richiesta CONNECT.
Altri errori proxy in questo riferimento
Codici di stato HTTP
- 401 Unauthorized vs 407
- 403 Forbidden
- 407 Proxy Authentication Required
- 429 Too Many Requests
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
Errori del browser e client
Errori di connessione e TLS
Proxy residenziali con documentazione che copre i casi di errore
Proxy residenziali CrawlRelay da 0,50 USD/GB, traffico che non scade mai.