101 Switching Protocols
Informational - Protocol upgrade accepted
HTTP 101 Switching Protocols
What It Means
The HTTP 101 Switching Protocols status code indicates that the server understands and is willing to comply with the client's request to switch protocols. The server will switch to the protocol specified in the Upgrade header.
Common Use Cases
- WebSocket connections: Upgrading from HTTP to WebSocket for real-time bidirectional communication
- HTTP/2 upgrade: Switching from HTTP/1.1 to HTTP/2 (less common, usually negotiated via ALPN)
- TLS upgrade: Upgrading an unencrypted connection to TLS
WebSocket Upgrade Example
# Client request
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
# Server response
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
# Connection is now WebSocket, not HTTP
Required Headers
| Header | Purpose |
|---|---|
| Upgrade | Protocol to switch to (e.g., "websocket") |
| Connection | Must be "Upgrade" |
Important Notes
- The connection switches immediately after the 101 response
- Cannot be used with HTTP/2 (uses different negotiation mechanism)
- The new protocol takes over the TCP connection entirely
- Server must include the Upgrade header in the response