505 HTTP Version Not Supported

What is the 505 Status Code?

The 505 HTTP Version Not Supported error is a server error code signaling that the server does not support the HTTP protocol version specified in the request. This error is part of the HTTP status code group, which is returned by a server when it appears unable to perform the request based on the client's specified HTTP version.

How and Why This Error Occurs

This error typically occurs when there is a mismatch between the HTTP versions supported by the client and the server. For example:

  • A client is using an outdated or a too recent version of a web browser that defaults to an unsupported HTTP version.
  • The server has not been updated to handle the HTTP version used by the client.
  • Misconfiguration on the server side, limiting it to a specific HTTP version.

This error is crucial to address as it prevents the client from accessing the requested web resources, leading to a poor user experience and potential loss of website traffic and revenue.

How to Diagnose the Error

Diagnosing the 505 HTTP Version Not Supported error involves checking both the client and server configurations to ensure they are using compatible HTTP versions. Below are the steps and corresponding code snippets to help diagnose the error:

Check Client Request

1. Using Browser Developer Tools:

  • Open the developer tools in your browser (usually F12 or right-click on the page and select 'Inspect').
  • Go to the 'Network' tab and send the request by refreshing the page.
  • Check the HTTP version in the request headers.

Check Server Configuration

2. Using Command Line:

You can use `curl` to send a request to the server and observe the response to check if it is causing the 505 error.

Example using curl:

curl -0 --http2 http://yourserver.com

The `-0` option tells `curl` to use HTTP 1.0, and `--http2` tells it to use HTTP 2. If the server does not support the version used, it may return a 505 error.

3. Server Logs:

Check the server logs for any entries related to the 505 error. The server logs can provide detailed information about the error and why it is occurring.

Example for checking Apache logs:

cat /var/log/apache2/error.log | grep '505'

Check Server Settings

4. Checking Server HTTP Version Support:

Ensure that your server is configured to support the HTTP version used in the client requests.

Example for Nginx:

Open the Nginx configuration file.

sudo nano /etc/nginx/nginx.conf

Check the `http` block to ensure the correct HTTP version is enabled.

5. Manually Send Requests:

Manually send requests to the server using different HTTP versions to check the server's response.

Example using Python requests:

import requests   
url = 'http://yourserver.com'
response = requests.get(url, headers={'Connection': 'close'})
print(f'Status Code: {response.status_code}')

This Python script sends a GET request to the server and prints out the status code of the response.

How to Fix the Error

Fixing the 505 HTTP Version Not Supported error involves ensuring that both the client and server are using compatible HTTP versions. Below are the steps and corresponding code snippets to help resolve the error:

1. Ensure Server Supports Required HTTP Version:

Update the server configuration to support the HTTP version used by the client.

Example for Nginx:  

# Open the Nginx configuration file.
sudo nano /etc/nginx/nginx.conf
# Ensure the http2 module is enabled in the listen directive.

listen 443 ssl http2 default_server;

2. Ensure Client Uses Supported HTTP Version:

Update the client (web browser or other client software) to use an HTTP version supported by the server.

Example in Curl:

# Use curl to send a request using HTTP 1.1.
curl --http1.1 http://yourserver.com

3. Update Server Software:

Ensure that the server software is up-to-date, as older versions may not support newer HTTP versions.

Example for Updating Apache on Ubuntu:

sudo apt update
sudo apt upgrade apache2

4. Update Client Software:

Ensure that the client software (web browser, API client, etc.) is up-to-date to support the required HTTP versions.

Example for Updating a Web Browser:

Typically, you can update a web browser in its settings or about a page.

5. Check Server Documentation:

Consult the server software documentation to ensure it is configured correctly to support the required HTTP versions.

If you find yourself in need of additional help, don't hesitate to reach out to our expert team.