SSL errors through a proxy usually have nothing to do with the website's certificate. The most common cause is a client trying to speak TLS to a proxy that expects plain HTTP, triggered by writing https:// where http:// belongs in the proxy URL. The second most common is something on your own machine or network intercepting TLS. This guide walks through each error message, what causes it, and the fix that doesn't involve turning verification off.
How HTTPS Through a Proxy Actually Works
When you fetch an https:// page through an HTTP proxy, your client first connects to the proxy in plain text and sends CONNECT example.com:443. The proxy opens a tunnel and replies "200 Connection established". Only then does your client start the TLS handshake, end to end with the website, inside that tunnel. The proxy never sees the decrypted traffic.
Two consequences follow. The connection to the proxy itself is plain HTTP, so the proxy URL should start with http://. And the certificate your client checks is the website's, so a certificate error means either the site's certificate is bad or something between you and the site replaced it.
Error: WRONG_VERSION_NUMBER or "record layer failure"
This is the classic one. In Python it looks like ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number, often wrapped in a ProxyError. Your client sent a TLS ClientHello to the proxy, the proxy answered in plain HTTP, and the TLS library couldn't parse the reply.
The cause is almost always the proxy URL scheme:
# Wrong: tells the client to use TLS to the proxy itself
proxies = {
"http": "http://USERNAME:[email protected]:8080",
"https": "https://USERNAME:[email protected]:8080",
}
# Right: plain HTTP to the proxy; TLS to the site happens inside the tunnel
PROXY = "http://USERNAME:[email protected]:8080"
proxies = {"http": PROXY, "https": PROXY}The dictionary key ("https") means "use this proxy for https:// URLs". The value's scheme (http://) means "talk to the proxy over plain HTTP". Mixing those up is easy. The same applies to curl: use -x http://... for the proxy even when the target is https://.
Pointing an HTTP client at the SOCKS5 port (1080) or a SOCKS client at the HTTP port (8080) produces similar garbled-handshake errors. Match the scheme to the port; SOCKS5 vs. HTTP proxies explains the difference.
Error: CERTIFICATE_VERIFY_FAILED or self-signed certificate in chain
Python reports [SSL: CERTIFICATE_VERIFY_FAILED]; Node reports SELF_SIGNED_CERT_IN_CHAIN or UNABLE_TO_GET_ISSUER_CERT_LOCALLY; curl reports "SSL certificate problem". Since a CONNECT proxy can't touch the certificate, look for these causes:
- Corporate network or antivirus TLS inspection. Many company firewalls and some antivirus products decrypt and re-sign traffic with their own root certificate. Your browser trusts it because IT installed it in the system store; Python and Node may not.
- A local debugging proxy left running, such as one you used for inspecting app traffic, still set as the system proxy.
- An outdated CA bundle. Old Python environments ship old certifi bundles; run pip install --upgrade certifi.
- Wrong system clock. Certificates have validity dates; a clock that's months off makes valid certificates look expired or not yet valid.
Check what certificate you actually receive through the proxy:
curl -v -x http://USERNAME:[email protected]:8080 https://example.com -o /dev/null 2>&1 | grep -E "subject:|issuer:"If the issuer is a well-known public CA, the chain is fine and the problem is your local trust store. If the issuer names your company, antivirus or a debugging tool, that tool is intercepting.
Trusting an intercepting CA correctly
If interception is legitimate (your employer's network), point your tools at the extra CA instead of disabling verification:
# Python requests
export REQUESTS_CA_BUNDLE=/path/to/company-ca-bundle.pem
# Node.js (adds to the built-in roots)
export NODE_EXTRA_CA_CERTS=/path/to/company-ca.pem
# curl
curl --cacert /path/to/company-ca-bundle.pem -x http://USERNAME:[email protected]:8080 https://example.comError: Handshake Failure or Unexpected EOF
SSLV3_ALERT_HANDSHAKE_FAILURE or "unexpected EOF while reading" during the handshake usually means the tunnel was set up but the connection was closed during TLS negotiation. Causes include a target that rejects old TLS versions or ciphers your library offers, an exit that dropped mid-handshake, and bot protection terminating connections with unusual fingerprints. Retry with a new IP first. If it fails consistently on one site but works in a browser, update your TLS library (OpenSSL, Python, Node) and see connection reset through a proxy.
Why verify=False Is the Wrong Fix
Turning off certificate verification (verify=False in Python, rejectUnauthorized: false or NODE_TLS_REJECT_UNAUTHORIZED=0 in Node, -k in curl) makes the error disappear by removing the check that protects you from interception. It also hides the real cause, so the WRONG_VERSION_NUMBER problem above would still be there. Use it only for a one-off diagnostic, never in production code.
Setting Up TLS Correctly with NodeProxies
Use http://USERNAME:[email protected]:8080 for both http and https targets, or socks5h:// on port 1080 for SOCKS5. The proxy format converter turns host:port:user:pass lines into the right URL format, and our proxy testing guide helps confirm the result. Create an account to get credentials.
FAQ
Why do I get SSL WRONG_VERSION_NUMBER with a proxy?
Your proxy URL probably starts with https:// instead of http://, so your client tries TLS with a proxy that speaks plain HTTP. Change the scheme to http://.
Can a proxy see my HTTPS traffic?
A standard CONNECT proxy only sees the hostname and port you connect to and the amount of data. The content is encrypted end to end between you and the website.
Should I use verify=False to fix proxy SSL errors?
No. It hides the cause and removes protection against interception. Fix the proxy scheme or add the correct CA bundle instead.
Why does the SSL error only happen through the proxy?
Most likely the proxy URL scheme is wrong, or a local tool intercepts only proxied traffic. Without the proxy your client speaks TLS directly to the site, which is why it works.
