426 Upgrade Required
The server refuses to handle the request over the current protocol, and its Upgrade header names the protocol to switch to.
What 426 Upgrade Required means
The server must send an Upgrade header listing the protocol it requires. If the client then asks to upgrade and the server agrees, the switch happens with 101 Switching Protocols.
A common case is a WebSocket endpoint receiving a plain HTTP request without the upgrade handshake.
Common causes
- A WebSocket endpoint opened as a normal web page or called with a plain HTTP client.
- A reverse proxy dropping the Upgrade and Connection headers before they reach the app.
- A server that requires a newer protocol than the client used.
How to fix 426 Upgrade Required
- Connect with a WebSocket client using ws:// or wss://, or with whatever protocol the Upgrade header names.
- In nginx, set proxy_http_version 1.1, proxy_set_header Upgrade $http_upgrade and proxy_set_header Connection "upgrade".
- Update the client or library if it does not support the required protocol.
Headers that go with it
UpgradeConnection
Example response
HTTP/1.1 426 Upgrade Required
Upgrade: HTTP/2.0
Content-Type: text/plain; charset=utf-8
426 Upgrade RequiredHow to check for a 426 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 426) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 426:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 426 {
fmt.Println(res.Status)
}Specification
426 Upgrade Required is defined in RFC 9110, section 15.5.22.
Related status codes
- 101
The server agrees to switch to the different protocol the client asked for in its Upgrade header, such as WebSocket.
- 505
The server does not support, or refuses to use, the major HTTP version the client used for the request.
- 400
The server could not understand the request because something in it is malformed, like broken JSON, bad syntax or invalid headers.