Do Proxies Support HTTP/2? Tunnels, ALPN and HTTP/3

Published:

10 minute read

Acar Diveroli
Written by: Acar Diveroli
A proxy box with a tunnel through it; blue glass at the client end reads h2, a CONNECT :443 plate floats above the box

HTTP/2 through a proxy is an HTTP/2 connection between the client and the target site, set up inside the proxy tunnel. The client asks the proxy for a CONNECT tunnel over HTTP/1.1. It then sets up TLS with the site inside that tunnel, and the HTTP version is chosen in that handshake through ALPN. The trap is on the client side: if the library does not offer HTTP/2, the connection silently stays on HTTP/1.1. This post covers the negotiation in the tunnel, the httpx and curl settings, and the proxy limit of HTTP/3.

Two conversations in the tunnel

A request to an HTTPS site through a proxy consists of two separate conversations. The first is between the client and the proxy. The client sends the line CONNECT example.com:443 HTTP/1.1, and the proxy answers with 200. As soon as this conversation ends, the proxy only carries bytes.

The second conversation runs inside the tunnel, between the client and the site. The TLS handshake, the certificate check and the HTTP version are settled here. The proxy stays out of this layer.

LayerWho talksProtocol
Tunnel requestClient ↔ proxyHTTP/1.1 CONNECT
EncryptionClient ↔ siteTLS, the proxy only relays
ApplicationClient ↔ siteHTTP/2 or HTTP/1.1, chosen by ALPN

The result is simple. The proxy does not need to know HTTP/2. In our test we used a short Python proxy that only understood HTTP/1.1. Through it, httpx spoke HTTP/2 with the site. We cover the differences between the versions themselves in HTTP/1.1 vs HTTP/2 vs HTTP/3.

ALPN negotiation

ALPN is the TLS extension in which the client lists the application protocols it can speak during the handshake. In its first message, the ClientHello, the client names protocols such as h2 and http/1.1. The server picks one of them. The name of HTTP/2 over TLS is h2.

Two details matter from the proxy's side. The ClientHello travels unencrypted. So the proxy can see the offer list. The proxy in our test read the first packet of each tunnel and logged the list:

text
PROXY <- CONNECT example.com:443 HTTP/1.1
PROXY    ClientHello ALPN offer: ['http/1.1', 'h2']
PROXY    tunnel closed, bytes up=1830 down=6315 (opaque)

The server's choice, however, comes back inside encrypted messages in TLS 1.3. The proxy does not see which version was chosen; it counts the bytes passing through the tunnel. The client side knows the choice: httpx reported HTTP/2 on this tunnel.

Devices that open the tunnel change this picture. A firewall that decrypts and re-encrypts TLS traffic negotiates ALPN with itself, not with the site. If the device does not support HTTP/2, the connection drops to HTTP/1.1. If you see HTTP/1.1 where you expect HTTP/2, the cause is often such a device in the path.

HTTP/2 with httpx

httpx supports HTTP/2 but keeps it off by default. Turning it on takes two steps: install the h2 package and pass http2=True to the client.

bash
pip install "httpx[http2]"
python
import httpx

proxy = "http://user:pass@pr.proxynet.io:8000"

with httpx.Client(proxy=proxy, http2=True) as client:
    r = client.get("https://example.com/")
    print(r.status_code, r.http_version)  # 200 HTTP/2

The proxy URL starts with http://, even though the target is HTTPS. httpx sends CONNECT to the proxy and offers h2 inside the tunnel. r.http_version returns the version actually spoken. If the site does not offer HTTP/2, the value is HTTP/1.1 and no error is raised.

If you pass http2=True without installing the h2 package, httpx stops while creating the client. In our test the message was: "Using http2=True, but the 'h2' package is not installed." If the package is there but http2=True is missing, the request goes over HTTP/1.1. In our test the offer list then contained only http/1.1.

curl and Requests

If curl is built with HTTP/2 support, it offers h2 on HTTPS sites by default. The curl docs say so in the description of the --http2 option. Check your build with curl -V: the Features line should list HTTP2.

bash
curl -sv -o /dev/null \
  -x http://user:pass@pr.proxynet.io:8000 \
  https://example.com/ 2>&1 | grep -E "ALPN|CONNECT|using HTTP"

The output shows the two stages separately. curl 8.23.0 in our test printed:

text
* CONNECT: no ALPN negotiated
> CONNECT example.com:443 HTTP/1.1
< HTTP/1.1 200 Connection Established
* CONNECT tunnel established, response 200
* ALPN: curl offers http/1.1
* ALPN: server accepted http/1.1
* using HTTP/1.x

The first line describes the conversation with the proxy. There is no ALPN there, because the connection to the proxy is plain HTTP. The ALPN: curl offers line shows the offer inside the tunnel. Our build lacked the HTTP2 feature. So curl offered only http/1.1, and --http2 stopped with the error "the installed libcurl version does not support this". In a build with HTTP/2 support, the offer line also includes h2.

Requests, on the other hand, speaks HTTP/1.1. In our request with Requests 2.34.2 through the same proxy, the offer list contained only http/1.1, and r.raw.version returned 11. If a Requests script needs HTTP/2, switch to httpx.

Plain HTTP targets

A target that starts with http:// has no tunnel. The client sends the full request URL to the proxy, and the proxy opens its own connection to the site. In this case the proxy decides which HTTP version the site sees.

Unencrypted HTTP/2 (h2c) has narrow use anyway. RFC 9113 deprecated the switch from HTTP/1.1 to h2c via Upgrade. What remains is only the "prior knowledge" path, where the client knows in advance that the server speaks HTTP/2. In our test, an httpx client opened with http2=True reported HTTP/1.1 for http://example.com/. The line that reached the proxy was GET http://example.com/ HTTP/1.1.

The practical rule: if you want HTTP/2, call the target over its HTTPS address.

HTTP/3 and UDP

HTTP/3 uses QUIC, a protocol that runs over UDP instead of TCP. An HTTP proxy tunnel, however, is a TCP connection. That is why HTTP/3 does not pass through an ordinary proxy tunnel.

Tools fall back to HTTP/2 in this case. Chromium's proxy documentation says that connections to HTTPS proxies can negotiate HTTP/2 but not QUIC. According to the same document, SOCKS5 in Chrome carries only TCP requests. The curl docs put it more briefly: curl cannot do HTTP/3 over any proxy. So a site that shows h3 on a direct visit and h2 through a proxy is behaving normally.

On paper there are two routes. RFC 9298 defines CONNECT-UDP, a method that carries UDP through an HTTP proxy. SOCKS5 can also relay UDP with the UDP ASSOCIATE command. The Proxynet SOCKS5 Proxy supports UDP. But it is the client that has to send QUIC packets this way. We did not verify that common HTTP/3 clients do this.

Don't try to force HTTP/3 through a proxy. A setup that runs on HTTP/2 is enough for most jobs.

Troubleshooting

The problem is usually in the client's offer list or in a device in the path. Check by symptom, in this order:

SymptomLikely causeWhat to do
http2=True but HTTP/1.1Site does not offer h2, or a TLS-decrypting device is in the pathTry the same request without the proxy
ImportError: ... 'h2' packageThe h2 package is not installedpip install "httpx[http2]"
curl --http2 not supportedBuild lacks the HTTP2 featureCheck with curl -V
h3 without proxy, h2 with proxyHTTP/3 does not pass a TCP tunnelNot a fault
407 responseWrong credentialsFix the user:pass part

If a site cuts an HTTP/2 connection with a protocol error, the problem is not the proxy but the side that corrupts the frames. We looked at the browser version of this in our err_http2_protocol_error post.

The first check is always the same. Make the request with and without the proxy and compare http_version in both results. If they match, the proxy is not affecting the version.

How we tested

We ran the tests on December 1, 2026, on Windows 11. Versions: Python 3.13.17, httpx 0.28.1, h2 4.4.1, httpcore 1.0.9, Requests 2.34.2 (urllib3 2.8.0) and curl 8.23.0 (Schannel, without the HTTP2 feature). The target was example.com.

As the proxy we used a local HTTP proxy written with asyncio. It understood only HTTP/1.1 and returned 407 without user:pass. It logged the CONNECT line and the ALPN offer list from the ClientHello, then relayed the bytes unchanged. When running the code examples, we used this local proxy's address instead of the one shown.

ScenarioClient offerResult
httpx, http2=True, HTTPShttp/1.1, h2HTTP/2
httpx, default, HTTPShttp/1.1HTTP/1.1
Requests, HTTPShttp/1.1HTTP/1.1 (raw.version 11)
curl 8.23.0, HTTPShttp/1.1HTTP/1.1
httpx, http2=True, plain HTTPNo tunnelHTTP/1.1

The bottom line

For HTTP/2 on an HTTPS target, configure the client: in httpx the h2 package and http2=True, in curl a build with the HTTP2 feature. On the proxy side, for example in a Residential Proxy setup, there is nothing to change. Above all, measure http_version instead of guessing it.

Sources

Frequently asked questions

Do proxies support HTTP/2?

Yes. On HTTPS sites, HTTP/2 is negotiated between the client and the site, inside the proxy tunnel. The proxy only answers the CONNECT request and relays the bytes. So the proxy does not need to know HTTP/2. What decides it is whether the client offers h2 and the site accepts it. In our test, httpx got HTTP/2 through a proxy that understood only HTTP/1.1.

Does Python Requests support HTTP/2?

No. Requests speaks HTTP/1.1. In our test with Requests 2.34.2, the TLS offer list contained only http/1.1, and r.raw.version returned 11. If you need HTTP/2, use httpx: install it with pip install "httpx[http2]" and open the client with http2=True. Its API is close to Requests, so the switch is short.

I set http2=True in httpx, why do I see HTTP/1.1?

The site may not offer HTTP/2. In that case httpx drops to HTTP/1.1 without an error. The second possibility is a security device in the path that decrypts TLS traffic. The device negotiates ALPN itself, and if it does not support HTTP/2, the version drops. Make the same request without the proxy and compare the r.http_version values. Also check that the target is https://, not http://.

Can the proxy see the content of my HTTP/2 traffic?

No. In an HTTPS tunnel the content is encrypted with TLS, and the proxy cannot read requests or responses. The proxy sees the host and port in the CONNECT line. Because the ClientHello travels unencrypted, it can also see the ALPN offer list. The version the server picks comes back encrypted in TLS 1.3. The proxy also knows how many bytes pass through the tunnel.

Does HTTP/3 work through a proxy?

Not with an ordinary HTTP proxy. HTTP/3 uses QUIC over UDP, while the CONNECT tunnel is TCP. That is why Chrome and curl fall back to HTTP/2 through a proxy. There are two ways to carry UDP: CONNECT-UDP (RFC 9298) and SOCKS5 UDP ASSOCIATE. Both require the client to support that route. Common browsers do not use them for web pages.

Can I use HTTP/2 with a SOCKS5 proxy?

Yes. SOCKS5 also opens a TCP connection to the target and relays the bytes without reading them. TLS and ALPN are again set up between the client and the site. So the HTTP/2 choice depends on the client, as with an HTTP proxy. Write the proxy URL as socks5h://user:pass@pr.proxynet.io:8000. In httpx, SOCKS support also needs the httpx[socks] package.

Ask ChatGPTAsk Claude