HTTP 505 HTTP Version Not Supported
Overview
The HTTP 505 HTTP Version Not Supported
status code indicates that the server does not support the HTTP protocol version used in the request. This response is sent when the server is incapable of supporting the major version of HTTP that was used in the request.
Purpose
The HTTP 505 response is used to inform the client that the server does not support the HTTP protocol version specified in the request.
Usage
Client Behavior:
- Send Request: The client sends an HTTP request with a specific HTTP protocol version.
- Receive Response: The client receives an HTTP 505 status code if the server does not support the specified HTTP version.
Server Behavior:
- Unsupported HTTP Version: The server determines that it cannot support the HTTP version specified in the request.
- Send Response: The server sends a
505 HTTP Version Not Supported
response to the client.
Scenarios
- Outdated HTTP Version: The client uses an outdated or unsupported HTTP version.
- Server Upgrade: The server has been upgraded, and the new version no longer supports the HTTP version used by the client.
Sequence Diagram
Illustrating the process for an HTTP 505 response:
sequenceDiagram participant Client participant Server Note over Client: Step 1: Client sends a request with HTTP/2 Client->>Server: GET /resource HTTP/2 (Step 1) Note over Server: Step 2: Server does not support HTTP/2 Server-->>Client: HTTP/1.1 505 HTTP Version Not Supported (Step 2)
Curl Request and Response Example
Sending a request using Curl with an unsupported HTTP version:
curl -i --http2 http://example.com/resource
# Expected response: HTTP/1.1 505 HTTP Version Not Supported
PHP cURL Request and Response Example
PHP script using cURL to handle a 505 HTTP Version Not Supported response:
<?php
$ch = curl_init('http://example.com/resource');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 505) {
echo "HTTP Version Not Supported";
}
curl_close($ch);
?>
Python Request and Response Example
Python script sending a request with an unsupported HTTP version and handling a 505 HTTP Version Not Supported response:
import requests
response = requests.get('http://example.com/resource', headers={'Connection': 'Upgrade', 'Upgrade': 'h2c'})
if response.status_code == 505:
print("HTTP Version Not Supported")
Apache Configuration for HTTP 505 HTTP Version Not Supported
Configuring Apache to handle 505 errors:
# Apache Configuration Example
ErrorDocument 505 "HTTP Version Not Supported"
NGINX Configuration for HTTP 505 HTTP Version Not Supported
NGINX configuration for handling 505 errors:
# NGINX Configuration Example
error_page 505 /505.html;
location = /505.html {
internal;
return 505 "HTTP Version Not Supported";
}
HTTP 504 Gateway Timeout HTTP 506 Variant Also Negotiates (Experimental)