HTTP
426 - Upgrade Required
Hitting a 426 Upgrade Required means the server refuses your request because it requires a protocol upgrade—using HTTP/1.0 when the server needs HTTP/1.1, or trying HTTP when HTTPS is mandatory. This client-side error (4xx) happens when servers enforce minimum protocol versions. Most common when legacy clients use HTTP/1.0 on servers requiring HTTP/1.1, but also appears when servers require TLS upgrades, WebSocket upgrades are mandatory, or security policies enforce protocol minimums.
#Common Causes
- →Frontend: Using HTTP/1.0 when server requires HTTP/1.1. Making HTTP requests when server requires HTTPS. Client library defaults to old protocol version. Browser using outdated HTTP version.
- →Backend: Server configuration requires HTTP/1.1 minimum. Security policy enforces TLS/HTTPS. Protocol upgrade middleware rejects old versions. Server explicitly requires protocol upgrade.
- →Infrastructure: Load balancer enforces protocol minimums. Reverse proxy requires protocol upgrade. API gateway rejects old protocol versions. WAF blocks outdated protocols.
✓Solutions
- 1Step 1: Diagnose - Check DevTools Network tab Protocol column—see which HTTP version is used. Review request URL (http:// vs https://). Check Upgrade header in response. Verify protocol negotiation.
- 2Step 2: Diagnose - Server logs show which protocol was rejected. Review server configuration for protocol requirements. Check if Upgrade header specifies required protocol. Verify infrastructure protocol settings.
- 3Step 3: Fix - Client-side: Upgrade to HTTP/1.1 or higher. Use HTTPS instead of HTTP. Update client libraries to support modern protocols. Let browser auto-negotiate protocol.
- 4Step 4: Fix - Server-side: Return 426 with Upgrade header showing required protocol. Configure server to accept HTTP/1.1 minimum. Implement protocol upgrade handling. Update security policies.
- 5Step 5: Fix - Infrastructure: Configure load balancer for protocol upgrades. Enable HTTPS redirects. Update reverse proxy protocol requirements. Review API gateway protocol settings.
</>Code Examples
Fetch API: Handle Protocol Upgrade
1// Client-side: Handle 426 by upgrading protocol
2async function fetchWithProtocolUpgrade(url) {
3 let response = await fetch(url);
4
5 if (response.status === 426) {
6 // Check Upgrade header for required protocol
7 const upgradeHeader = response.headers.get('Upgrade');
8 console.warn(`Protocol upgrade required: ${upgradeHeader}`);
9
10 // Upgrade to HTTPS if HTTP was used
11 if (url.startsWith('http://')) {
12 const httpsUrl = url.replace('http://', 'https://');
13 console.log(`Upgrading to HTTPS: ${httpsUrl}`);
14 response = await fetch(httpsUrl);
15 }
16
17 // Or check Upgrade header for specific protocol
18 if (upgradeHeader && upgradeHeader.includes('TLS')) {
19 // Upgrade to HTTPS
20 const urlObj = new URL(url);
21 urlObj.protocol = 'https:';
22 response = await fetch(urlObj.toString());
23 }
24 }
25
26 return response;
27}
28
29// Usage
30fetchWithProtocolUpgrade('http://api.example.com/endpoint')
31 .then(response => response.json())
32 .catch(error => console.error('Protocol upgrade failed:', error));Express.js: Require Protocol Upgrade
1// Server-side: Return 426 for protocol upgrades
2const express = require('express');
3const app = express();
4
5// Middleware to require HTTP/1.1 or higher
6app.use((req, res, next) => {
7 const httpVersion = req.httpVersion;
8
9 if (httpVersion === '1.0') {
10 return res.status(426)
11 .set('Upgrade', 'HTTP/1.1')
12 .set('Connection', 'Upgrade')
13 .json({
14 error: 'Upgrade Required',
15 message: 'Server requires HTTP/1.1 or higher',
16 upgrade: 'HTTP/1.1',
17 });
18 }
19
20 next();
21});
22
23// Require HTTPS
24app.use((req, res, next) => {
25 if (req.protocol !== 'https' && process.env.NODE_ENV === 'production') {
26 return res.status(426)
27 .set('Upgrade', 'TLS/1.2')
28 .set('Connection', 'Upgrade')
29 .json({
30 error: 'Upgrade Required',
31 message: 'Server requires HTTPS',
32 upgrade: 'TLS/1.2',
33 });
34 }
35 next();
36});
37
38// Redirect HTTP to HTTPS
39app.use((req, res, next) => {
40 if (req.protocol === 'http' && process.env.NODE_ENV === 'production') {
41 return res.redirect(301, `https://${req.get('host')}${req.originalUrl}`);
42 }
43 next();
44});Nginx: Force Protocol Upgrade
1# Nginx: Configure protocol upgrade requirements
2server {
3 listen 80;
4 server_name api.example.com;
5
6 # Redirect HTTP to HTTPS (upgrade required)
7 return 301 https://$server_name$request_uri;
8}
9
10# HTTPS server
11server {
12 listen 443 ssl http2;
13 server_name api.example.com;
14
15 # SSL/TLS configuration
16 ssl_certificate /etc/ssl/certs/api.example.com.crt;
17 ssl_certificate_key /etc/ssl/private/api.example.com.key;
18
19 # Require HTTP/1.1 minimum
20 # Nginx automatically handles this, but you can add custom logic
21
22 location /api/ {
23 proxy_pass http://backend;
24 proxy_set_header Host $host;
25 proxy_set_header X-Real-IP $remote_addr;
26 proxy_set_header X-Forwarded-Proto $scheme;
27
28 # Pass protocol version to backend
29 proxy_set_header X-Protocol-Version $server_protocol;
30 }
31
32 # Custom 426 response if needed
33 # error_page 426 @upgrade_required;
34 # location @upgrade_required {
35 # return 426 '{"error":"Upgrade Required","upgrade":"HTTP/1.1"}';
36 # add_header Upgrade "HTTP/1.1" always;
37 # add_header Connection "Upgrade" always;
38 # }
39}↗Related Errors
Provider Information
This error code is specific to HTTP services. For more information, refer to the official HTTP documentation.