The server agrees to switch protocols as requested by the client via an Upgrade header.
The 101 Switching Protocols status code indicates that the server understands and is willing to comply with the client's request to change the application protocol being used on this connection. The server will switch to the protocol defined in the response's Upgrade header immediately after the empty line that terminates the 101 response.
A 101 response is returned when the client sends a request with an Upgrade header asking the server to switch to a different protocol, and the server agrees. The most common scenario is a WebSocket handshake, where the client requests an upgrade from HTTP/1.1 to the WebSocket protocol.
The client initiates the switch by including Connection: Upgrade and Upgrade: websocket headers (along with a security key). If the server supports WebSocket and accepts the request, it responds with 101 and the connection transitions from HTTP to a full-duplex WebSocket channel.
Sec-WebSocket-Accept value by concatenating the key with the magic GUID and returning the Base64-encoded SHA-1 hash.proxy_set_header Upgrade $http_upgrade and proxy_set_header Connection "upgrade" to forward WebSocket upgrades.GET /chat 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=
Track uptime, latency, and connection health for your real-time services around the clock.
Start Free Monitoring