# HTTP 426 Upgrade Required — Meaning, Causes & Fixes

> The server refuses the request over the current protocol and asks the client to upgrade.

426 means 'not like this — switch protocols first'. The server sends an `Upgrade` header naming the protocol it requires, such as WebSocket or a newer HTTP version. Unlike 101, which agrees to an upgrade the client asked for, 426 demands one the client didn't ask for.

- Class: 4xx Client Error
- Retry: No — change the request first
- Cacheable by default: no
- Defined in: [RFC 9110 §15.5.22 — 426 Upgrade Required](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.22)

## Example response

```http
HTTP/1.1 426 Upgrade Required
Upgrade: websocket
Connection: Upgrade
Content-Type: application/json
Content-Length: 28

{"error":"Upgrade Required"}
```

## Common causes

- Calling a WebSocket-only endpoint with a plain HTTP request.
- Servers that require a newer HTTP version or TLS.

## How to fix it

1. Connect with the protocol named in the `Upgrade` header — for WebSockets, `new WebSocket("wss://…")`.
2. Make sure proxies aren't stripping the `Upgrade` header from your request.

## Send a 426 from your server

### Express

```
res.set("Upgrade", "websocket");
res.set("Connection", "Upgrade");
res.status(426).json({ error: "Upgrade Required" });
```

### Next.js route handler

```
return Response.json({ error: "Upgrade Required" }, { status: 426, headers: { "Upgrade": "websocket", "Connection": "Upgrade" } });
```

### Flask

```
return {"error": "Upgrade Required"}, 426, {"Upgrade": "websocket", "Connection": "Upgrade"}
```

### Go net/http

```
w.Header().Set("Upgrade", "websocket")
w.Header().Set("Connection", "Upgrade")
http.Error(w, "Upgrade Required", http.StatusUpgradeRequired)
```

### nginx

```
add_header Upgrade "websocket" always;
add_header Connection "Upgrade" always;
return 426;
```

## FAQ

### 426 vs 101?

101: the server agrees to switch to the protocol you requested. 426: the server refuses to continue until you switch.

## Related status codes

- [101 Switching Protocols](https://www.devkult.com/http/101.md)
- [505 HTTP Version Not Supported](https://www.devkult.com/http/505.md)
- [400 Bad Request](https://www.devkult.com/http/400.md)

Open the interactive page: https://www.devkult.com/http/426