101 Switching Protocols

A protocol change during an active HTTP session is signaled by the 101 Switching Protocols informational response status code. The server sends this response when the client includes the Upgrade request header along with the required Connection: upgrade header.

Usage

Clients including the Upgrade request header want the server to use a different protocol for the remainder of the HTTP session. Multiple protocols are listed on a single line, comma-delimited, in order of descending preference. The protocol version is optional.

Connection: upgrade
Upgrade: protocol-name[/protocol-version]

The request is made when there is a benefit to doing so, such as taking advantage of features offered by more recent protocol versions. This upgrade is only supported by HTTP/1.1, and a client has no way to force the server to change protocols. The upgrade is optional, and the server returns 200 when the Upgrade header is ignored.

Server-side request

The server has no way to force a client to upgrade protocols, but the server refuses requests when a client fails to meet requirements. When a client sends a request using a protocol the server does not support, the server returns 426. Using the protocol directed by the server, the client has subsequent requests accepted and processed.

Example

The client requests an upgrade from HTTP/1.1 to the WebSocket protocol. The server accepts and switches protocols.

Request

GET /chat HTTP/1.1
Host: www.example.re
Connection: upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==

Response

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

WebSocket and protocol layer

WebSocket connections begin as HTTP requests and upgrade through the 101 handshake. After the upgrade completes, the connection operates as a persistent, full-duplex TCP channel at the application layer (layer 7). The HTTP framing is replaced by the WebSocket frame format. Server-Sent Events (SSE) are an alternative for server-to-client streaming without requiring a protocol upgrade.

Code references

.NET

HttpStatusCode.SwitchingProtocols

Rust

http::StatusCode::SWITCHING_PROTOCOLS

Rails

:switching_protocols

Go

http.StatusSwitchingProtocols

Symfony

Response::HTTP_SWITCHING_PROTOCOLS

Python3.5+

http.HTTPStatus.SWITCHING_PROTOCOLS

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_SWITCHING_PROTOCOLS

Angular

@angular/common/http/HttpStatusCode.SwitchingProtocols

See also

Last updated: April 4, 2026