HTTP 101 Switching Protocols: What It Means and When You See It
Quick Answer
HTTP 101 Switching Protocols indicates the server is switching to the protocol specified in the Upgrade header field. Commonly used when upgrading to WebSocket connections.
When You Will See HTTP 101
HTTP 101 is returned when a client requests a protocol upgrade and the server agrees. The two primary use cases are WebSocket connections and HTTP/2 upgrades. For WebSockets: the client sends Upgrade: websocket and Connection: Upgrade headers; the server responds with 101 and the connection switches from HTTP to the WebSocket protocol. After this, full-duplex communication is possible. For Server-Sent Events (SSE), the connection stays HTTP but switches to streaming mode. HTTP 101 is never seen in normal REST API calls - it only appears in real-time application protocols.
Debugging HTTP 101 Issues
If you expect a WebSocket connection but get a different response, check: (1) the server supports WebSockets and has the upgrade handler registered, (2) proxies or load balancers are configured to pass Upgrade headers (nginx: proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"), (3) SSL/TLS is consistently used - mixing ws:// and wss:// causes failures. In Node.js with the ws library: const wss = new WebSocket.Server({ server }); wss.on("connection", (ws) => { ws.on("message", (msg) => console.log(msg)); }). The 101 response means the handshake succeeded.
HTTP 101 in Code
JavaScript (browser): const ws = new WebSocket("wss://api.example.com/socket"); ws.onopen = () => console.log("Connected"); ws.onmessage = (event) => console.log(event.data). Node.js (ws library): import WebSocket from "ws"; const ws = new WebSocket("wss://api.example.com/socket"); ws.on("open", () => ws.send("hello")). The browser fetch() API cannot trigger HTTP 101 - WebSocket connections must use the WebSocket constructor or a library like socket.io. HTTP 101 responses have no body; all subsequent communication happens over the upgraded protocol.
Try the interactive tool
Convert any value instantly — no sign-up required
Frequently Asked Questions
Related Values
100
HTTP 100 Continue means the server has received the request headers and the client should proceed to send the request body. It is an interim response used to inform the client to continue.
200
HTTP 200 OK is the standard success response. The request has succeeded and the server has returned the requested resource in the response body.
201
HTTP 201 Created means the request succeeded and a new resource was created as a result. The Location header typically points to the new resource URL.
204
HTTP 204 No Content means the server successfully processed the request but is not returning any content. Common for DELETE requests or form submissions.