Skip to main content
101

Switching Protocols

Active
RFC 9110 §15.2.2Since 1997WebSocket upgrades

HTTP 101 Switching Protocols indicates the server is switching to a different protocol as requested by the client via the Upgrade header. Defined in RFC 9110 §15.2.2. Most commonly seen when upgrading an HTTP connection to WebSocket.

Description

The 101 Switching Protocols status code indicates 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 generate an Upgrade header field in the response that indicates which protocol(s) will be in effect after this response. This is the mechanism used to establish WebSocket connections from an initial HTTP handshake.

Examples

WebSocket upgrade request
http
GET /chat HTTP/1.1
Host: example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
Server response
http
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

Edge Cases

  • Only applies to HTTP/1.1. HTTP/2 and HTTP/3 do not support the Upgrade mechanism.
  • The server must switch protocols immediately after sending the 101 response.
  • If the upgrade fails after 101 is sent, the connection must be closed.

When You'll See This

  • Establishing WebSocket connections
  • Upgrading HTTP/1.1 to HTTP/2 (h2c cleartext)
  • Legacy protocol transitions

Implementation References

LanguageConstant
Gohttp.StatusSwitchingProtocols
Rusthttp::StatusCode::SWITCHING_PROTOCOLS
Pythonhttp.HTTPStatus.SWITCHING_PROTOCOLS
Node.jshttp.STATUS_CODES[101]
.NETHttpStatusCode.SwitchingProtocols
JavaHttpURLConnection.HTTP_SWITCHING_PROTOCOLS

History

Introduced in HTTP/1.1 (RFC 2068, 1997). Became critical with the WebSocket protocol (RFC 6455, 2011) which uses this mechanism for the initial handshake.

Related Status Codes

Related Headers

FAQ

What does HTTP 101 Switching Protocols mean?

HTTP 101 means the server is changing to a different protocol (like WebSocket) as requested by the client via the Upgrade header.

Is HTTP 101 used for WebSocket?

Yes. The WebSocket handshake uses HTTP 101 to upgrade from HTTP to the WebSocket protocol. After the 101 response, communication switches to WebSocket frames.