101 Switching Protocols

The server is switching to the protocol the client asked for.

When to use it

Upgrading a connection to WebSocket.

Good to know

You almost always see 101 during a WebSocket handshake: the client sends Upgrade: websocket and Connection: Upgrade, and the server answers 101 with Sec-WebSocket-Accept. If you get 200, 400 or 426 instead, something in between dropped the Upgrade headers. Behind nginx you must forward them explicitly with proxy_http_version 1.1, proxy_set_header Upgrade $http_upgrade and proxy_set_header Connection upgrade.

After the switch, idle timeouts become the next problem: nginx closes proxied connections after proxy_read_timeout, 60 seconds by default, and AWS ALB has a 60-second idle timeout, so quiet sockets need pings. HTTP/2 doesn’t use 101 at all; WebSockets over HTTP/2 use extended CONNECT from RFC 8441. A 101 has no body and is never cached.

Informational (1xx)

1xx codes are informational: the server has received the request and the exchange continues. Browsers and HTTP libraries handle them for you.

What it looks like

HTTP/1.1 101 Switching Protocols

How to check it

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

Open HTTP Status Codes