HTTP 101 Switching Protocols

HTTP 101 Switching Protocols means the server is agreeing to switch from HTTP to a different protocol, as requested by the client in the Upgrade header. This is the response that initiates WebSocket connections — the HTTP handshake is complete and both client and server switch to the WebSocket protocol.

HTTP 101 full guide →

Quick reference

Code101
NameSwitching Protocols
Category1xx Informational
SpecificationRFC 9110 §15.2.2
IANA statusAssigned
CacheableNo — not cached
Client actionSwitch to the new protocol specified in the Upgrade header for all further communication.
In-depth guideHTTP 101 full guide →

What HTTP 101 means

RFC 9110 defines 101 as indicating that the server understands and is willing to comply with the client's request, via the Upgrade header field, for a change in the application protocol being used on this connection. The server must send an Upgrade header in the response indicating which protocol it is switching to.

After the 101 response is sent, the connection changes protocol. For WebSocket connections, this means the HTTP framing ends and WebSocket frames begin. The HTTP/1.1 connection is upgraded to a full-duplex bidirectional channel.

101 only applies to HTTP/1.1 connections. HTTP/2 does not use the Upgrade mechanism — WebSocket connections over HTTP/2 use a different negotiation mechanism (RFC 8441, Extended CONNECT).

WebSocket upgrade handshake

The WebSocket connection begins with a standard HTTP/1.1 request with specific upgrade headers:

GET /ws HTTP/1.1
Host: example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

After this exchange, the TCP connection is no longer HTTP — all further data is WebSocket frames. The server computes Sec-WebSocket-Accept by hashing the client's Sec-WebSocket-Key with a fixed GUID, proving it understood the WebSocket handshake.

Other protocol upgrades

WebSocket is by far the most common use of 101, but the mechanism supports any protocol upgrade. HTTP/2 cleartext (Upgrade: h2c) was another use case — a way to upgrade an HTTP/1.1 connection to HTTP/2 without TLS. In practice, h2c over Upgrade is rarely implemented now; most HTTP/2 connections use TLS with ALPN negotiation instead.

FAQ

What does HTTP 101 Switching Protocols mean?

HTTP 101 means the server agreed to the client's request to switch protocols. For WebSocket connections, it means the HTTP handshake is complete and both sides now communicate using the WebSocket protocol.

Why do WebSocket connections start with HTTP?

WebSocket was designed to work through existing HTTP infrastructure — web servers, proxies, and firewalls. Starting with an HTTP handshake (that gets upgraded to WebSocket via 101) allows WebSocket to use standard HTTP ports (80, 443) and pass through most network equipment transparently.

What happens if the server rejects the upgrade?

The server returns an error response — typically 400 Bad Request or 426 Upgrade Required (if the server requires a protocol upgrade). The connection remains HTTP and the upgrade does not occur.

Does 101 work with HTTP/2?

No. The Upgrade mechanism is specific to HTTP/1.1. HTTP/2 WebSocket connections use Extended CONNECT (RFC 8441) instead of the 101 upgrade mechanism.

Related resources

On this site: HTTP 101 Switching Protocols — full guide · HTTP 100 Continue · HTTP 426 Upgrade Required

Standards: RFC 9110 §15.2.2 · RFC 6455 (WebSocket) · IANA HTTP Status Code Registry · MDN Web Docs: 101