4264xx
4xx — Client Error
Upgrade Required
The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
What it means
The HTTP 426 Upgrade Required client error response code indicates that the server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
The server sends an `Upgrade` header with this response to indicate the required protocol(s).
How it works
- 1The client sends an HTTP/1.1 request.
- 2The server is strictly configured to only accept HTTP/2 or WebSockets.
- 3The server returns 426 with an 'Upgrade: h2c' or 'Upgrade: websocket' header.
Why you're seeing this
- • Connecting to a WebSocket endpoint without the proper handshake headers.
- • Server enforcing TLS/HTTP2.
How to fix it
- • Update the client to support the required protocol.
Framework Implementations
Express.js
app.get('/ws', (req, res) => {
if (req.headers.upgrade !== 'websocket') {
return res.status(426).set('Upgrade', 'websocket').send('Upgrade Required');
}
});Real-Life Scenarios
Use this when forcing clients to migrate to a newer protocol version for security or performance reasons.
WebSocket Handshake Failure
A client tries to fetch a WebSocket URL using a standard GET request without the 'Upgrade' headers. The server returns 426.
HTTP Transaction
1. Client Request
GET / HTTP/1.1 Host: example.com
2. Server Response
HTTP/1.1 426 Upgrade Required Upgrade: HTTP/2.0 Connection: Upgrade
SEO Implications
None.