Use it on every public HTTPS site; browsers negotiate it with ALPN h2. It removes most of the need for multiple connections and domain sharding.
HTTP/2
TCP → TLS with ALPN h2 → connection preface + SETTINGS → streams carrying HEADERS/DATA frames → flow-control windows → GOAWAY on shutdown
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Read-only Verification Verify boundary
# Negotiated version (prints 2 for HTTP/2)
curl -sS -o /dev/null --http2 -w "%{http_version}\n" https://www.example.com/
# ALPN result from the TLS handshake
openssl s_client -alpn h2,http/1.1 -connect www.example.com:443 -servername www.example.com </dev/null 2>/dev/null | grep -i alpn
# -> ALPN protocol: h2
# Verbose: shows "using HTTP/2" and stream activity
curl -v --http2 https://www.example.com/ -o /dev/null
No ALPN negotiated means the server (or a TLS-terminating device in front of it) does not offer h2. The origin may still speak HTTP/2 to a CDN while the CDN speaks it to clients — test each hop separately.
Step 2 Common mistakes Narrow the fault
- Keeping HTTP/1.1 optimisations (sharding, sprites, concatenation) after enabling HTTP/2.
- Relying on server push.
- Expecting HTTP/2 between proxy and backend by default — most proxies speak HTTP/1.1 upstream unless configured otherwise.
- Forgetting that a CDN negotiates HTTP/2 with clients independently of the origin.
Step 3 Troubleshooting Narrow the fault
Clients fall back to HTTP/1.1. h2 not enabled on the TLS listener, an old TLS library without ALPN, or a middlebox terminating TLS without h2.
ERR_HTTP2_PROTOCOL_ERROR in the browser. Often a response header the server or proxy sends that HTTP/2 forbids (connection-specific headers such as Connection, Keep-Alive, Transfer-Encoding), or a buffering/proxy bug. Check the server error log and whether it happens through every hop.
421 Misdirected Request. Connection coalescing sent a request for another hostname over an existing connection; serve both names consistently or use separate certificates/IPs.
Slow on lossy networks. HTTP/2 multiplexing is on one TCP connection; packet loss stalls all streams. Consider HTTP/3.
curl -sS -o /dev/null --http2 -w "%{http_version}\n" https://<host>/— prints 2 when h2 was negotiated.openssl s_client -alpn h2 -connect <host>:443 -servername <host> </dev/null 2>/dev/null | grep ALPN— server selected h2.- nginx:
http2 on;in the server block (1.25.1+); Apache:Protocols h2 http/1.1.
ReferenceWhat it is2 sections · depth on demand
Direct Answer
HTTP/2 (RFC 9113) sends the same HTTP requests and responses as binary frames on independent streams, so one TCP connection can carry many requests at once. Headers are compressed with HPACK, and flow control works per stream and per connection. Browsers use HTTP/2 only over TLS, negotiated with ALPN h2; cleartext HTTP/2 (h2c) is used between servers by prior knowledge. Its remaining weakness is TCP itself: one lost packet delays every stream on the connection, which HTTP/3 solves by moving to QUIC.
Scope and canonical references
- Shared semantics: HTTP.
- Predecessor and fallback: HTTP/1.1.
- Successor over QUIC: HTTP/3 and QUIC.
- TLS and ALPN: TLS under Web Services and the TLS protocol Topic TLS in Security.
- Server configuration: Nginx, Apache, IIS.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Framing and streams
After TLS, the client sends a connection preface and both sides exchange SETTINGS (acknowledged). Each request uses a new odd-numbered stream: a HEADERS frame, then DATA frames. Frames from different streams interleave, so a slow response no longer blocks the others at the HTTP layer.
| Frame | Purpose |
|---|---|
| HEADERS / CONTINUATION | Compressed header block |
| DATA | Body bytes (subject to flow control) |
| SETTINGS | Connection parameters, e.g. max concurrent streams, initial window |
| WINDOW_UPDATE | Flow-control credit; new streams start with 65,535 bytes |
| RST_STREAM | Cancel one stream |
| GOAWAY | Graceful shutdown or fatal error; tells the client the last stream processed |
| PING | Liveness and RTT |
HPACK keeps a dynamic table of previously sent headers per direction, so repeated headers such as cookies and user agents shrink to a few bytes.
Negotiation
- Over TLS: ALPN token
h2in the TLS handshake. If the server does not select it, the client uses HTTP/1.1. - Cleartext:
h2cby prior knowledge (the client starts with the preface directly) — common for gRPC and proxy-to-backend links. The HTTP/1.1Upgrade: h2cmechanism is deprecated.
RFC 9113 obsoletes RFC 7540 and deprecates the original priority scheme. Server push is still in the specification, but Chrome and Firefox have removed support; use 103 Early Hints or <link rel=preload> instead.
Operational consequences
- One connection per origin: domain sharding and resource concatenation, used for HTTP/1.1, are counter-productive.
- Connection coalescing: a browser may reuse one connection for several hostnames if they resolve to the same IP and the certificate covers them. A server that does not serve one of those names should answer 421 Misdirected Request.
- Load balancers see fewer, longer-lived connections; balancing per connection becomes coarser.
- The Rapid Reset attack (CVE-2023-44487, 2023) abused stream creation and RST_STREAM; keep servers patched and limit concurrent streams.
Enabling it
| Server | Configuration |
|---|---|
| nginx 1.25.1+ | http2 on; in the TLS server block (older versions: listen 443 ssl http2;) |
| Apache httpd | LoadModule http2_module … and Protocols h2 http/1.1 |
| IIS 10 | Enabled by default for HTTPS bindings on supported Windows Server versions |
| Caddy | Enabled by default |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.