HTTP 101 Switching Protocols

The server is switching to the protocol the client asked for in its Upgrade header, usually WebSocket.

Switching Protocols

1xx InformationalStandardRFC 9110, section 15.2.2

The server is switching to the protocol the client asked for in its Upgrade header, usually WebSocket.

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

What 101 means

The server agrees to switch protocols on this connection, as the client asked in its Upgrade header. After the blank line that ends the 101 response, both sides speak the new protocol.

When servers send it

Almost always when a browser opens a WebSocket over HTTP/1.1. The client sends Connection: Upgrade and Upgrade: websocket, and the server answers 101 with the protocol it switched to. (Over HTTP/2 and HTTP/3, WebSockets use a different mechanism and 101 isn’t used.)

Why you might see it

  • A WebSocket handshake that succeeded.
  • Rarely, an upgrade from HTTP/1.1 to cleartext HTTP/2 (h2c), which is now deprecated.

Using it as a developer

  • If your WebSocket never gets a 101, check the proxy in front of your app. nginx needs proxy_http_version 1.1 and must pass the Upgrade and Connection headers on.
  • A 400 or 426 instead of 101 usually means the server wants a different Sec-WebSocket-Version or the request is missing a header.
  • A 200 instead of 101 means something in the middle handled the request as normal HTTP and the upgrade was lost.

If you’re visiting a website

  • Nothing. This is a healthy sign that a live connection (chat, notifications) has started.

Related codes

  • 100 Continue: The server has the request headers and the client should go ahead and send the body.
  • 426 Upgrade Required: The server won’t handle this request over the current protocol. The Upgrade header says which to switch to.
  • 400 Bad Request: The server can’t or won’t handle the request because something in it is malformed.

Where it’s defined

101 Switching Protocols is defined in RFC 9110, section 15.2.2. It’s a 1xx code, the informational class: the request was received and is still being processed.

Other 1xx codes

100 Continue · 103 Early Hints

Or search them all in the HTTP status code list.

Questions people ask

What does HTTP 101 Switching Protocols mean?
The server is switching to the protocol the client asked for in its Upgrade header, usually WebSocket.
Why does my WebSocket connection fail behind nginx?
By default nginx talks HTTP/1.0 to the backend and drops hop-by-hop headers, so the upgrade is lost. Set proxy_http_version 1.1, and pass proxy_set_header Upgrade $http_upgrade and proxy_set_header Connection "upgrade".
Does HTTP/2 use 101?
No. HTTP/2 forbids 101. WebSockets over HTTP/2 use an extended CONNECT request instead (RFC 8441).
↑↓ move↵ openesc close