Informational · 1xx

101 Switching Protocols

The server is switching protocols as requested by the client, typically upgrading from HTTP/1.1 to WebSocket.

What 101 Switching Protocols means

101 Switching Protocols is the response that establishes a WebSocket connection. The client sends a normal HTTP/1.1 GET request with Upgrade: websocket and Connection: Upgrade headers; the server responds with 101 and the connection then becomes a WebSocket carrying its own framed protocol. You also see 101 used for HTTP/2 upgrades over cleartext (h2c), though most modern HTTP/2 uses TLS ALPN instead.

When servers should return it: Servers return 101 when they accept an Upgrade request and switch the connection to a different protocol. After 101, the connection is no longer HTTP.

Example response

curl --include --no-buffer \
  --header "Connection: Upgrade" \
  --header "Upgrade: websocket" \
  --header "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
  --header "Sec-WebSocket-Version: 13" \
  https://example.com/ws

Related status codes

Frequently Asked Questions

Is 101 the same as a successful WebSocket connection?
Yes. After receiving 101, the client and server speak WebSocket over the same TCP connection.
Do HTTP/2 or HTTP/3 use 101?
HTTP/2 over TLS uses ALPN (no 101). HTTP/2 over cleartext (h2c) uses 101 to upgrade. HTTP/3 over QUIC has no upgrade dance.
Can I refuse an Upgrade?
Yes. The server can simply respond with a normal HTTP status (200, 400, etc.) and ignore the upgrade headers.
Defined in: RFC 9110 · Class: 1xx Informational

More references

For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.