HTTP 426 Upgrade Required indicates the server refuses to perform the request using the current protocol but would be willing to do so if the client upgrades to a different protocol. The server MUST include an Upgrade header indicating the required protocol(s). This is used to enforce HTTPS (Upgrade: TLS/1.2), HTTP/2 (Upgrade: h2c), or WebSocket connections on endpoints that require them.
Response includes the status code, standard headers (including Content-Type), and a small diagnostic JSON body describing the request and returned status.
Simulator URL (copy in the app after load — not a normal link):
https://httpstatus.com/api/status/426
Example request:
curl -i "https://httpstatus.com/api/status/426"The client should switch to a different protocol (e.g., TLS/1.0). The server sends an Upgrade header indicating the required protocol.
On this code, Inspector focuses on semantics, headers, and correctness warnings that commonly affect clients and caches.
HTTP 426 Upgrade Required has specific technical implications for API design, caching, and client behavior. Understanding the precise semantics helps distinguish it from similar status codes and implement correct error handling. The response should include a descriptive body following a consistent error schema (like RFC 7807 Problem Details) so clients can programmatically handle the error.
// Handle 426 Upgrade Required in Express
app.use((err, req, res, next) => {
if (err.status === 426) {
return res.status(426).json({
type: 'https://api.example.com/errors/upgrade-required',
title: 'Upgrade Required',
status: 426,
detail: err.message
});
}
next(err);
});from fastapi import HTTPException
# Raise 426 Upgrade Required
raise HTTPException(
status_code=426,
detail={
'type': 'upgrade_required',
'message': 'Descriptive error for 426 Upgrade Required'
}
)// Spring Boot 426 Upgrade Required handling
@ExceptionHandler(CustomUpgradeRequiredException.class)
public ResponseEntity<ErrorResponse> handleUpgradeRequired(
CustomUpgradeRequiredException ex) {
return ResponseEntity.status(426)
.body(new ErrorResponse("Upgrade Required", ex.getMessage()));
}// Return 426 Upgrade Required
func errorHandler(w http.ResponseWriter, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(426)
json.NewEncoder(w).Encode(map[string]any{
"status": 426,
"error": "Upgrade Required",
"message": message,
})
}