HTTP CONNECT Explained: How HTTPS Traffic Passes Through a Proxy (2026)

What really happens when HTTPS goes through a proxy: the CONNECT handshake byte by byte, what the proxy can still see, and when TLS interception breaks the rules.

Author
ProxyHorizon Team
Published
November 26, 2026
15 min read
Expert-Verified
HTTP CONNECT Explained: How HTTPS Traffic Passes Through a Proxy (2026)

Your browser sends an HTTPS request through a proxy. The proxy forwards it. But it never reads a word of it.

That sounds like a contradiction, and it confuses plenty of developers. How does a server pass traffic it can’t understand? And if it can’t read your traffic, why does your company proxy still block pages by name?

The answer is one small HTTP method called CONNECT. It turns a proxy into a blind pipe for encrypted bytes.

We built a tiny HTTP CONNECT proxy in Python, sent real traffic through it, and logged exactly what it saw. The list is shorter than most people expect, with one big exception that decides whether your traffic is private at all.

TL;DR
  • Every HTTPS request through an HTTP proxy starts with a CONNECT request.
  • After a 200 reply, the proxy only copies encrypted bytes it can’t read.
  • The proxy still sees the hostname, timing, data volume and your proxy login.
  • A proxy can only read HTTPS if your device trusts its certificate authority.
  • CONNECT errors happen before TLS, so the status code points straight at the proxy.

What the HTTP CONNECT Method Does

CONNECT asks a proxy to open a raw TCP connection to a host and port, then step aside and copy bytes in both directions. After that, the proxy stops behaving like an HTTP server and becomes a tunnel.

The official definition lives in RFC 9110, section 9.3.6. It says the proxy should “restrict its behavior to blind forwarding of data, in both directions, until the tunnel is closed.” Blind is the key word.

Here’s why that matters. HTTPS is encrypted end to end between your client and the website. A normal proxy that reads and rewrites requests would break that encryption. CONNECT avoids the problem by never trying to read the request at all.

So every time you set an HTTP proxy in Chrome, curl, Python or an antidetect browser and then visit an https:// URL, your client quietly sends a CONNECT first. You rarely see it. It’s still there, on every connection.

If you want the bigger picture of how a proxy sits between you and a site first, our guide on how proxies work covers the basics.

Plain HTTP vs HTTPS Through a Proxy

For plain HTTP, the proxy reads and forwards the full request. For HTTPS, it only sees a CONNECT line with a hostname and port. That single difference explains most proxy behavior you’ll run into.

We pointed curl 8.14.1 at our test proxy twice: once with an http:// URL and once with https://. Here’s what the proxy logged for the plain HTTP request:

HTTP
GET http://example.com/ HTTP/1.1
Host: example.com
User-Agent: curl/8.14.1
Accept: */*
Proxy-Connection: Keep-Alive

Notice the full URL in the first line. This is called the absolute form. The proxy sees the path, every header, any cookies and the body. It could log it, cache it or change it.

And here’s the HTTPS request to the same site:

HTTP
CONNECT example.com:443 HTTP/1.1
Host: example.com:443
User-Agent: curl/8.14.1
Proxy-Connection: Keep-Alive

No path. No cookies. No real request headers. Just the destination host and port, plus whatever curl chooses to tell the proxy itself. The actual GET / happens later, inside the encrypted tunnel.

What the proxy can seePlain HTTP via proxyHTTPS via CONNECT tunnelHTTPS via TLS-intercepting proxy
Destination hostname and portYesYesYes
Full URL path and query stringYesNoYes
Request headers and cookiesYesNoYes
Page content and form dataYesNoYes
Proxy login (Proxy-Authorization)YesYesYes
Timing and data volumeYesYesYes
Can modify the contentYesNoYes

That last column is the twist. We’ll come back to it, because it’s where the “a proxy can’t read HTTPS” rule stops being true.

The CONNECT Handshake, Step by Step

A CONNECT tunnel takes three stages: the CONNECT request, the proxy’s 200 reply, and a normal TLS handshake that runs straight through the proxy. Only after all three does your real request go out.

Flow diagram of an HTTP CONNECT proxy tunnel: client sends CONNECT, proxy replies 200, then TLS runs end to end to the website
The proxy only takes part in the first exchange. After the 200 reply, it just copies encrypted bytes.

1The Client Sends CONNECT

The client opens a TCP connection to the proxy, not to the website. Then it sends a short request with the target in authority form, meaning just host:port.

RFC 9110 is strict here: there’s no default port, so the client must always include one. A request like CONNECT example.com HTTP/1.1 without :443 is invalid, and a compliant proxy should answer 400 Bad Request.

The exact bytes are tiny. A minimal one, like the request our raw-socket client sends below, is 59 bytes, ending with a blank line (\r\n\r\n) to mark the end of the headers. A CONNECT request never has a body.

2The Proxy Opens a Socket and Replies

The proxy resolves the hostname, opens its own TCP connection to example.com:443 and, if that works, answers:

HTTP
HTTP/1.1 200 Connection Established

The wording after 200 doesn’t matter. Per the RFC, any 2xx response means the tunnel is live from the very next byte. Anything else means it isn’t, and the client should give up on this connection.

This is also where the proxy decides whether to say no. A proxy that needs a login replies 407. One that can’t reach the target replies 502 or 504. One that blocks the destination replies 403. More on those in the troubleshooting section.

3TLS Runs Through the Tunnel

Now the client starts a normal TLS handshake, exactly as if it were talking to the website directly. The proxy forwards each packet without understanding it.

Our curl run negotiated TLS 1.3 with the real example.com certificate, through the proxy, and then sent its HTTP/2 request inside the encrypted channel. The proxy never held a key and never saw the request.

When either side closes, the proxy closes the other side too. RFC 9110 says it should first flush any data still in flight, then drop both connections.

We Built a Working CONNECT Proxy in 40 Lines

The fastest way to understand a tunnel is to run one. This is the learning proxy we used for every log in this article. It handles CONNECT only, which is all HTTPS needs.

Python
# Minimal HTTP CONNECT proxy for learning. Not for production use.
import asyncio

async def pipe(reader, writer):
    try:
        while data := await reader.read(65536):
            writer.write(data)
            await writer.drain()
    finally:
        writer.close()

async def handle(client_r, client_w):
    request_line = (await client_r.readline()).decode("latin-1").strip()
    headers = []
    while (line := await client_r.readline()) not in (b"\r\n", b""):
        headers.append(line.decode("latin-1").strip())
    print("Proxy saw:", request_line)
    for h in headers:
        print("  header:", h)
    method, target, _ = request_line.split(" ", 2)
    if method != "CONNECT":
        client_w.write(b"HTTP/1.1 405 Method Not Allowed\r\n\r\n")
        await client_w.drain(); client_w.close(); return
    host, port = target.rsplit(":", 1)
    try:
        up_r, up_w = await asyncio.open_connection(host, int(port))
    except OSError:
        client_w.write(b"HTTP/1.1 502 Bad Gateway\r\n\r\n")
        await client_w.drain(); client_w.close(); return
    client_w.write(b"HTTP/1.1 200 Connection Established\r\n\r\n")
    await client_w.drain()
    # From here on the proxy only copies bytes. It can't read them.
    await asyncio.gather(pipe(client_r, up_w), pipe(up_r, client_w))

async def main():
    server = await asyncio.start_server(handle, "127.0.0.1", 8888)
    async with server:
        await server.serve_forever()

asyncio.run(main())

Run it with python3 connect_proxy.py (Python 3.8 or newer, no extra packages), then test it from another terminal:

Bash
curl -v --proxy http://127.0.0.1:8888 https://example.com/

We tested this on Python 3.13.5 with curl 8.14.1 in November 2026. curl returned the page with HTTP 200, and the proxy printed only the CONNECT line and three headers.

Look at the comment near the bottom of the code. Once the 200 goes out, the proxy only runs two copy loops. That’s the whole “tunnel.” Everything clever about HTTPS proxying happens in the client and the website, not in the middle.

Warning: this is a teaching tool. It has no authentication, no port allowlist and no timeouts. Expose it to the internet and you’ve built an open relay for anyone who finds it.

Doing the Handshake by Hand With Raw Sockets

Libraries hide the CONNECT step, so here it is with nothing but Python’s standard library. This client talks to the proxy, opens the tunnel, then wraps the same socket in TLS.

Python
import socket, ssl

PROXY = ("127.0.0.1", 8888)
TARGET_HOST, TARGET_PORT = "example.com", 443

sock = socket.create_connection(PROXY, timeout=10)
sock.sendall(
    f"CONNECT {TARGET_HOST}:{TARGET_PORT} HTTP/1.1\r\n"
    f"Host: {TARGET_HOST}:{TARGET_PORT}\r\n\r\n".encode()
)
reply = b""
while b"\r\n\r\n" not in reply:
    reply += sock.recv(4096)
print(reply.split(b"\r\n")[0].decode())        # HTTP/1.1 200 Connection Established

# The tunnel is open. Start TLS with the real site, through the proxy.
ctx = ssl.create_default_context()
tls = ctx.wrap_socket(sock, server_hostname=TARGET_HOST)  # SNI is sent here
print(tls.version(), tls.getpeercert()["subject"])
tls.sendall(b"GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n")
print(tls.recv(200).split(b"\r\n")[0].decode())  # HTTP/1.1 200 OK
tls.close()

Our run printed three lines: HTTP/1.1 200 Connection Established, then TLSv1.3 with the certificate subject example.com, then HTTP/1.1 200 OK.

The interesting line is server_hostname=TARGET_HOST. That’s where Python puts the website’s name into the TLS ClientHello as SNI. It’s also the one piece of the encrypted session a CONNECT proxy can still read, which leads to the next question.

Terminal output from curl through a local HTTP CONNECT proxy showing the CONNECT request, 200 Connection Established and the TLS 1.3 handshake
Real curl 8.14.1 output from our test, trimmed to the tunnel steps. Captured November 2026.

What a CONNECT Proxy Can Still See

A CONNECT proxy can’t read your pages, but it still learns where you go, when, and roughly how much you send. That metadata is often enough to profile someone.

1The Hostname, Twice

The destination appears in the CONNECT line itself. It usually appears again in the TLS ClientHello as the SNI field, which is sent unencrypted in most TLS connections today.

That’s how corporate proxies block “facebook.com” without breaking encryption. They don’t need the URL. The hostname is enough.

Encrypted Client Hello (ECH) can hide the SNI from network observers, but it doesn’t help against the proxy. The CONNECT line already named the host in plain text. A client could connect by IP address instead, though shared hosting and CDNs make that impractical for most sites.

2Your Proxy Credentials

If the proxy needs a login, the client sends it in a Proxy-Authorization header on the CONNECT request. With Basic auth, that’s just Base64, not encryption.

When we ran curl with --proxy-user demo:secret, our proxy logged Proxy-Authorization: Basic ZGVtbzpzZWNyZXQ=. Decode that string and you get demo:secret. Anyone on the network between you and an http:// proxy can do the same.

Real-world tip: if your provider offers an HTTPS proxy endpoint (TLS to the proxy itself), the CONNECT request and your credentials travel encrypted too. Otherwise, prefer IP whitelisting or other proxy authentication methods on untrusted networks.

3Timing, Size and the Client’s Own Headers

The proxy sees when each tunnel opens and closes and how many bytes flow each way. Traffic analysis on those patterns can sometimes guess which page you loaded on a known site.

It also sees whatever headers your client adds to the CONNECT request itself. curl sent its User-Agent there. Python’s requests 2.34.2 sent only the Host header, as our log showed. That difference is a small fingerprint in its own right.

Tunnel vs TLS Interception: When a Proxy Reads HTTPS After All

A TLS-intercepting proxy answers CONNECT with a 200, then pretends to be the website using a certificate it forged on the fly. It only works if your device trusts the proxy’s own certificate authority.

The mitmproxy documentation lays out the trick openly. The tool replies to CONNECT as if it opened a pipe, waits for the SNI in your ClientHello, connects to the real server with that name, copies the real certificate’s names, and generates a matching fake certificate signed by its own CA.

Comparison of a blind CONNECT tunnel that keeps HTTPS encrypted end to end versus a TLS-intercepting proxy that decrypts traffic
Same CONNECT request, very different privacy. The certificate your device trusts decides which one you get.

Your browser accepts that fake certificate only because someone installed the proxy’s CA as trusted. On a work laptop, IT usually does this through device management. On your own phone, a debugging tool asks you to install it.

Where you’ll meet interception in real life:

  • Corporate secure web gateways that scan downloads and enforce data-loss rules.
  • Antivirus “HTTPS scanning” features that run a local intercepting proxy.
  • Developer tools such as mitmproxy, Charles and Fiddler, used to debug apps.
  • Malicious setups, where an attacker tricks you into trusting a rogue certificate.

How to tell: click the padlock and look at who issued the site’s certificate. If a well-known site shows an issuer named after your employer, your antivirus or a debugging tool, the connection is being intercepted.

Commercial proxy providers don’t need your CA, and a normal residential or datacenter proxy has no way to read your HTTPS traffic without it.

If any provider asks you to install a root certificate to “make the proxy work,” treat that as a red flag. Our list of vetted proxy providers is a safer starting point.

Why Proxies Restrict CONNECT Ports

An unrestricted CONNECT proxy can tunnel to any service on the internet, so well-run proxies only allow port 443 and a few others. It’s a security rule, not a bug.

RFC 9110 gives the classic abuse case: CONNECT example.com:25 would let a stranger send email through your proxy, which is how open proxies end up relaying spam. The spec says proxies “SHOULD restrict its use to a limited set of known ports.”

Squid, the most common open-source proxy, ships with exactly that rule. Its documented default config includes:

Text
acl SSL_ports port 443
http_access deny CONNECT !SSL_ports

In plain English: CONNECT is allowed to port 443 and denied everywhere else. That’s why tunneling SSH (port 22) or a database port through an office proxy usually fails with 403.

Commercial proxy networks set their own rules. Many block port 25 outright and some limit tunnels to web ports. If a non-HTTPS tool fails only through the proxy, check the provider’s port policy before debugging your code. For raw TCP to arbitrary ports, a SOCKS5 proxy is usually the better fit.

CONNECT in HTTP/2 and HTTP/3

In HTTP/2 and HTTP/3, CONNECT tunnels a single stream instead of taking over the whole connection. One connection to the proxy can carry many tunnels at once.

RFC 9113, section 8.5 defines the HTTP/2 version. The request uses the :method pseudo-header set to CONNECT and an :authority of host:port, with no :scheme or :path. Tunnel data then rides in DATA frames on that stream.

Classic CONNECT only carries TCP. That’s a problem for QUIC and HTTP/3, which run over UDP. RFC 9298 (August 2022) adds CONNECT-UDP, the building block of the IETF’s MASQUE work, so HTTP proxies can relay UDP the same way.

Should you care? For scraping and everyday proxy use, not much yet. Most clients still speak HTTP/1.1 to the proxy even when they speak HTTP/2 to the site, as our curl log showed with “CONNECT tunnel: HTTP/1.1 negotiated.”

Troubleshooting CONNECT Errors

CONNECT failures come from the proxy, before TLS starts, so the status code tells you exactly which side to fix. Here are the ones you’ll actually see.

What you seeWhat it meansFix
407 Proxy Authentication RequiredMissing or wrong proxy login on the CONNECTCheck username, password and encoding of special characters; or whitelist your IP
403 Forbidden on CONNECTThe proxy blocks that host or portUse port 443, check the provider’s blocked-domain list, or switch to SOCKS5
502 Bad GatewayThe proxy couldn’t open a socket to the targetCheck the hostname and port; retry with a different exit IP
504 Gateway TimeoutThe target didn’t answer the proxy in timeRaise timeouts, retry, or test the site directly
400 Bad RequestMalformed CONNECT, often a missing portAlways send host:port
TLS error right after a 200The tunnel opened but TLS failed inside itCheck certificate errors, clock skew, or a TLS-intercepting proxy

We triggered a 502 on purpose by asking our test proxy to CONNECT 127.0.0.1:9, a port with nothing listening. curl printed “CONNECT tunnel failed, response 502” and never started TLS. That’s the pattern to recognize: the error comes from the proxy, so your target site never saw a thing.

For the full list, see our guide to proxy error codes.

Common mistake: writing your proxy URL as https:// when the provider only runs a plain HTTP listener. The scheme in the proxy URL describes the connection to the proxy, not the website. For most providers, http://user:pass@host:port is correct even for HTTPS sites, because CONNECT handles the encryption.

How Common Tools Send CONNECT

Almost every client sends CONNECT automatically for HTTPS URLs, but they differ in the details. Those details matter when something breaks.

ClientHow to set the proxyWorth knowing
curl--proxy http://host:port or -x-v shows the CONNECT exchange; -p forces a tunnel even for http:// URLs
Python requestsproxies={"https": "http://host:port"}Sends a minimal CONNECT with only the Host header in our test
BrowsersOS or browser proxy settings, or a PAC fileEvery HTTPS site gets its own CONNECT, reused for many requests
Playwright, Puppeteer, SeleniumLaunch options or a --proxy-server flagCredentials go in the CONNECT, not in page requests

If you work with these daily, our hands-on guides for curl with a proxy and Python requests proxies go deeper on auth, rotation and timeouts.

One more thing for scrapers. CONNECT hides your requests from the proxy, but it doesn’t change how the website sees your TLS handshake. Your ClientHello reaches the site untouched, so TLS fingerprinting still identifies your client library no matter which proxy you use.

Frequently Asked Questions

The Bottom Line on CONNECT Tunnels

CONNECT is the reason HTTPS and proxies get along. The proxy opens a socket, says 200, and from then on it’s a blind pipe that sees hosts, timing and your proxy login, but not your pages.

Our take: the real privacy question is never “does the proxy use CONNECT?” It always does. The question is whether anything on your device trusts a certificate it shouldn’t. Check the certificate issuer once, keep proxy credentials off plain HTTP on public Wi-Fi, and you’ve covered most of the risk.

Next step: run the 40-line proxy above, point curl at it with -v, and watch a tunnel open. Then compare the HTTP, HTTPS and SOCKS5 proxy types to pick the right one for your project.