This tutorial will explain everything about the HTTP 406 Not Acceptable status code. The HTTP 406 Not Acceptable is an HTTP response or status code belonging to 4xx client errors. This means that the page cannot be reached, is unavailable, or the request has bad syntax. The error signals that the server cannot provide content in the format requested in the headers of the client’s request. The HTTP 406 error can appear while you are visiting some websites. It can also appear on the website you are hosting.
In the following paragraphs, we will explain this error in more detail. What causes it, and how to fix it from the client and website owner’s perspectives. Let’s get started!
Table of Contents
What is the HTTP 406 Error?
The HTTP 406 Error is related to the Accept header in the client’s request. This header lists the content types the client can accept as a response. If the server can provide those content types, the status code is HTTP 200. This indicates that everything is ok with the website. Otherwise, if the server cannot provide the content, the browser will throw the HTTP 406 Not Acceptable error. The browser shows this error “complaining” that the server sent an incorrect file format or it violates some security requirements. In the next paragraph, let’s see what causes this error.
What Caused the 406 Error?
One of the reasons for the website to throw the HTTP 406 error is the mod_security rule. The mod_security is a security module in the Apache web server enabled by default after the Apache installation. If the server violates a rule set by the browser or the client machine, it sends the HTTP 406 error. Accept Ranges, Accept Encoding, Accept-charset, Accept-language, and MIME type violations are examples of bad formats or rule violations that come with the header requests. These headers need to be checked and reviewed, and more about fixing the HTTP 406 error.
How to Fix the HTTP 406 Error?
Fixing the HTTP 406 error can be done by a client or a server owner, depending on what is related to the issue. Let’s assume first that you are a client trying to access some website, and suddenly, the HTTP 406 Error Not Acceptable is all you see in the browser. In the next paragraphs, we will provide some steps that must be applied for the issue to disappear.
Check the URL: The most straightforward step is to check the URL you are accessing. For example, if you use .php or .json at the end of the URL, it can be easily misinterpreted, and the browser will throw an error.
Clearing the web browser cache and cookies can sometimes help solve the issue. The cache may store older website content previously served while the requests were in the wrong formats, but the server owner fixed the problem.
Check the Request Headers: The HTTP 406 error is related to the Accept header in the client request. This header specifies the media type the client can accept as a response. For example, the Accept header for accepting JSON format is:
Accept: application/json
An example of an Accept header for accepting JSON and XML is:
Accept: application/json, application/xml
Use More Generic Types: If you are getting the HTTP 406 Error, you can use wildcards or more generic types in the Accept header as explained below:
Accept: */*
What to do if you’re the Website Owner
Now, let’s assume that you are the website owner, and you are hosting the website. You can follow the steps below to fix the HTTP 406 Error:
Check the web server logs: The first step for troubleshooting any issue related to the server is checking the logs. In the logs, you can find plenty of information about the application, including the cycle of the requests, steps, and other information about how the application is working.
Check the Web Server Configuration: Ensure that the web server configuration file is configured correctly to handle the content of the requested formats. If the web server is misconfigured, the web browser may throw the HTTP 406 Not Acceptable error.
Rolling back the latest changes is the next step that you need to do if you suspect that the updated website files caused the error. If you have a backup of the previous version of the website files and the database dump, restore it and see if that will fix the issue.
Disable the mod_security temporarily to see if the issue will appear or not. You can disable the mod_security rules, disable the mod_security for specific domains, or altogether disable it on a server level.
Contact Hosting Support: If you cannot fix the issue on your own, the last thing to do is contact the support of the hosting company where the website is hosted. Or better, this can be the first step if you do not have time to investigate the issue on your own and if you have fully managed support.
Congratulations
That’s it. You learned some steps to fix the browser’s HTTP 406 Not Acceptable Status Code.
Of course, you do not have to fix this alone if you have an NVMe VPS hosting plan with us. All you have to do is submit a support ticket or initiate a live chat with our technical support. Do not hesitate to contact us anytime. We are available 24/7.
PS. If you liked this post on fixing the HTTP 406 error, please share it with your friends on social networks or leave a comment in the comments section. Thank you.