426

Upgrade Required

Overview

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.

When it happens

Request / Response example

Request
GET /socket HTTP/1.1
Host: api.example.com
Response
HTTP/1.1 426 Upgrade Required
Upgrade: TLS/1.3, HTTP/1.1
Connection: Upgrade
Content-Type: text/plain

This service requires an upgraded protocol.

In code

app.get('/socket', (req, res) => {
  if (req.headers.upgrade !== 'websocket') {
    return res.status(426)
      .set('Upgrade', 'websocket')
      .set('Connection', 'Upgrade')
      .send('Upgrade Required');
  }
});

Common causes

How to fix

Notes

Related status codes

Related headers

Specification