101 Switching Protocols means: The server agrees to switch the application protocol on this connection, as requested by the client's Upgrade header. The connection stops speaking HTTP/1.1 and becomes the negotiated protocol, most commonly WebSocket. Informational 1xx responses are interim signals sent before the final answer: they keep the client informed or coordinate a protocol switch while the real work continues. Application code rarely handles them directly because HTTP libraries absorb them, but intermediaries must forward them correctly or handshakes stall. In practice you will meet 101 when a websocket handshake (upgrade: websocket) completes successfully; an http/1.1 connection is upgraded to http/2 cleartext (h2c) via the upgrade mechanism; a proxy tunnels a protocol switch requested by the client. On the client side, after receiving 101, stop treating the socket as HTTP and hand it to the protocol implementation (e.g. the WebSocket API). Do not send further HTTP requests on it. On the server side, only answer 101 when you actually support the requested protocol and include the correct Upgrade and Connection headers; load balancers must allow connection upgrades end to end.
When 101 happens
- A WebSocket handshake (Upgrade: websocket) completes successfully
- An HTTP/1.1 connection is upgraded to HTTP/2 cleartext (h2c) via the Upgrade mechanism
- A proxy tunnels a protocol switch requested by the client
How to fix it
On the client
After receiving 101, stop treating the socket as HTTP and hand it to the protocol implementation (e.g. the WebSocket API). Do not send further HTTP requests on it.
On the server
Only answer 101 when you actually support the requested protocol and include the correct Upgrade and Connection headers; load balancers must allow connection upgrades end to end.
Should you retry?
No retry: the connection has switched protocol; hand it to the new protocol stack.
Debugging steps
When 101 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Interim responses are invisible to most high-level clients, so use curl -v or a raw socket to observe them; a missing 1xx usually means an intermediary swallowed it. For this code specifically, check whether the most common trigger applies to your situation: a websocket handshake (upgrade: websocket) completes successfully. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.
Notes & gotchas
After 101 the connection is no longer HTTP: any intermediary that buffers, inspects or terminates upgrades will break the WebSocket, so every hop needs explicit upgrade support.
Examples
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
curl -i -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" https://ws.example.com/socket const res = await fetch("https://api.example.com/v1/resource");
if (res.ok) {
const data = await res.json(); // 101 Switching Protocols
return data;
} import requests
res = requests.get("https://api.example.com/v1/resource", timeout=10)
res.raise_for_status()
data = res.json() # 101 Switching Protocols Frequently asked questions
Does every WebSocket connection start with 101?
Yes, over HTTP/1.1 the handshake ends with 101 Switching Protocols. HTTP/2 and HTTP/3 use extended CONNECT instead, so you will not see 101 there.
Why does my WebSocket fail behind a load balancer?
Many LBs buffer or terminate upgrades. Enable WebSocket/upgrade support on every hop, or use a passthrough (TCP) listener.
Do I need to handle 1xx responses in my application code?
Usually no — HTTP clients and browsers process interim responses internally and surface only the final status. You care about 1xx when writing proxies, low-level sockets or debugging stalled handshakes.
Are 1xx responses errors?
No — they are progress and coordination signals, not failures. The final status arrives afterwards; treating an interim response as the answer is a low-level client bug.
Try the JSON Validator
Check JSON syntax and locate errors by line and column.