1xx InformationalCommonly usedRFC 9110

101Switching Protocols

Server is switching to the protocol requested by the client.

What it means

The server agrees to switch protocols as requested by the client via the Upgrade header. Most commonly used when upgrading an HTTP connection to a WebSocket connection.

When to use it

  • Upgrading HTTP to WebSocket
  • Upgrading HTTP/1.1 to HTTP/2
  • Any protocol upgrade negotiation

Code Examples

WebSocket upgrade
javascript
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

// HTTP → WebSocket upgrade returns 101
wss.on('connection', (ws) => {
  ws.on('message', (message) => {
    ws.send(`Echo: ${message}`);
  });
});

Don't confuse with

Quick Facts

Code101
CategoryInformational
SpecRFC 9110
CommonYes

Relevant Headers

Upgrade

Specifies the protocol to switch to (e.g. websocket)

Connection

Must include "Upgrade"

Related Codes

← Back to all status codes