# HTTP 101 Switching Protocols — Status Code Meaning & Examples

> The server agrees to switch the connection to another protocol, most often WebSocket.

101 is the server saying yes to an `Upgrade` request. The client asks — for example with `Upgrade: websocket` and `Connection: Upgrade` — and the server replies 101 with the same `Upgrade` header. From that moment the TCP connection stops speaking HTTP/1.1 and carries the new protocol instead. Every WebSocket connection over HTTP/1.1 begins this way.

- Class: 1xx Informational
- Retry: Not applicable
- Cacheable by default: no
- Defined in: [RFC 9110 §15.2.2 — 101 Switching Protocols](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.2.2)

## Example response

```http
HTTP/1.1 101 Switching Protocols
```

## When you'll see it

- A WebSocket handshake succeeded (`new WebSocket("wss://…")` in the browser).
- A client requested an HTTP/1.1 to cleartext HTTP/2 (h2c) upgrade — rare, since browsers only use HTTP/2 over TLS.

## What to do

1. If you expected 101 but got 200 or 400, the server or a proxy in front of it doesn't pass the upgrade through. nginx needs `proxy_http_version 1.1;`, `proxy_set_header Upgrade $http_upgrade;` and `proxy_set_header Connection "upgrade";`.
2. A 426 Upgrade Required means the server insists on a protocol you didn't ask for.
3. HTTP/2 and HTTP/3 don't use 101; WebSockets over HTTP/2 use extended CONNECT (RFC 8441) instead.

## FAQ

### Why does my WebSocket work locally but fail behind nginx?

nginx proxies with HTTP/1.0 and drops hop-by-hop headers by default, so the Upgrade request never reaches your app. Add proxy_http_version 1.1 and forward the Upgrade and Connection headers.

### Does a 101 response have a body?

No. After the 101 headers, every byte on the connection belongs to the new protocol.

## Related status codes

- [426 Upgrade Required](https://www.devkult.com/http/426.md)
- [100 Continue](https://www.devkult.com/http/100.md)
- [400 Bad Request](https://www.devkult.com/http/400.md)

Open the interactive page: https://www.devkult.com/http/101