426 Upgrade Required means the server will not handle the request over the current protocol and the client must switch to a different one. The required protocol is named in the response's Upgrade header.
For example, it is returned when you connect over plaintext HTTP but the server requires TLS, or when a plain HTTP request hits an endpoint that expects a WebSocket upgrade.
GET /socket HTTP/1.1
Host: api.example.comHTTP/1.1 426 Upgrade Required
Upgrade: TLS/1.3, HTTP/1.1
Connection: Upgrade
Content-Type: text/plain
This service requires an upgraded protocol.app.get('/socket', (req, res) => {
if (req.headers.upgrade !== 'websocket') {
return res.status(426)
.set('Upgrade', 'websocket')
.set('Connection', 'Upgrade')
.send('Upgrade Required');
}
});