101 Switching Protocols
The server agrees to change protocol on this connection, which in practice almost always means upgrading to WebSocket.
At a glance
- Status code
- 101 Switching Protocols
- Class
- 1xx, informational, an interim response before the real one
- Defined in
- RFC 9110
- Cacheable by default
- no
- Response body
- No body in the HTTP sense. The connection is handed to the new protocol.
In detail
The client asked with Upgrade and Connection: Upgrade, the server accepted, and from the blank line onward the bytes on the socket belong to the new protocol rather than to HTTP.
The WebSocket handshake is the only common use. The response must echo the negotiated protocol in its own Upgrade header and, for WebSocket, carry a Sec-WebSocket-Accept value derived from the client key.
If a WebSocket connection fails with 200 or 400 instead of 101, the request usually reached a proxy or load balancer that does not forward Upgrade headers.
Examples
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=Things that catch people out
- HTTP/2 has no Upgrade mechanism. WebSocket over HTTP/2 uses the extended CONNECT method instead, and never returns 101.
- Content-Length and Transfer-Encoding have no meaning on a 101 response, because nothing after the headers is an HTTP message.
Try it: HTTP Request Builder
Build a request with any method, headers and body, send it, and read the status line the server returns.
HTTP Request Builder
LOCAL · Browser-OnlyBuild and test HTTP requests with custom headers and body
Authentication
Headers
Generate Code
curl -X GET 'https://api.example.com/endpoint' \
-H 'Content-Type: application/json'Showing a sample URL. Enter your endpoint above to update the snippet.
Related HTTP status codes
All http status codes →426 Upgrade Required
The server refuses to serve this request over the current protocol and names, in the Upgrade header, what it will accept.
400 Bad Request
The server refused the request because it was malformed. The client must change something before retrying, because repeating the same bytes will fail.
200 OK
The request succeeded. What the body contains depends on the method: a GET returns the resource, a POST returns the result of the action.
102 Processing
A WebDAV interim response meaning the request was received and is still being worked on, sent to stop the client timing out.
103 Early Hints
An interim response that sends Link headers early so the browser can start preloading assets while the server is still building the real response.
201 Created
The request succeeded and created one or more new resources. The Location header carries the URL of the primary one.
Tools for this
- HTTP Request Builder Free online HTTP request builder - build and test HTTP requests with custom headers and body
- HTTP Headers Checker Free online HTTP headers checker - view HTTP response headers for any URL