On Encountering an HTTP 421 Error
One-line summary
Let’s stop using HTTP/1.1.
Detailed notes
- Symptom:
- A 421 (Misredirected Request) error occurred on the CDN server
- The end user’s web browser received a 200 OK response, but the file actually returned was abnormal
- Cause: When there are two CDNs using the same host name, SNI behaves unstably under HTTP/1.1 (it sends the request to the wrong host)
- Fix: Configure it to use only the HTTP/2 protocol, which strictly manages TCP connection reuse
- What does “strictly manages TCP connections” mean?
- HTTP/1.1 performs SNI based only on the Host in the request header, so when a TCP connection is reused, it may send the request to the wrong host that merely shares the same Host.
- HTTP/2 reuses a TCP connection only after verifying the Host, port, and TLS certificate all together.
- What does “strictly manages TCP connections” mean?
Of course, the 421 error can still occur under HTTP/2. But it’s still better than HTTP/1.1.
EOD
20250903
Leave a comment