101 Switching Protocols means the server agreed to the protocol change the client asked for via the Upgrade header. After this response the same TCP connection stops speaking ordinary HTTP and switches to the negotiated protocol.
The most common real-world use is upgrading from HTTP to WebSocket. The Sec-WebSocket-Accept value in the response proves the server validated the client's key, and from that point on the connection carries bidirectional real-time traffic.
GET /chat HTTP/1.1
Host: example.com
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=const ws = new WebSocket('wss://example.com/chat');
ws.onopen = () => ws.send('hello');
// the 101 handshake happens transparently before onopenimport { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });
wss.on('connection', s => s.send('welcome')); // library sends 101