What is HTTP Error 406 Not Acceptable – How to Fix It?
Regardless of what may be causing them, server errors are without doubt frustrating both for users visiting your website and for you as the website owner. While some HTTP errors are more common than others, it’s always good to be prepared for any error that your web server may throw at you. Luckily, HTTP Error 406 Not Acceptable is not as common as 404, 500 or 301 HTTP codes are, but you may encounter it nonetheless, and when you do, the cause is usually one of the following two: a content type negotiation problem or misunderstanding or a mod_security rule setting problem, the latter being the most common of the two.
This article sheds light on why a server returns a HTTP error 406 Not Acceptable and what can you do to fix the underlying problem.
Stop Getting Errors on Your Website!
InMotion Hosting offers reliable hosting service and top-notch 24/7 online support. Click here to get 47% discount!
HTTP Error 406 Caused by an Accept Header Problem
When a client (web browser) wants to load a webpage, first it needs to obtain the IP address of the server. To this end, it does a DNS lookup, which translates the domain.com to an IP address. The DNS might return multiple IP addresses; in that case, it will pick the first one and establish a TCP Socket connection to port 80 or 443 to that IP address. Upon a successful connection, it will write the HTTP request data (e.g. GET / HTTP/1.1, Host: domain.com, Accept: text/html, User-Agent: Mozilla …).
The server, after it receives a request, depending on the Accept header, it might return a 406 status code indicating that it cannot send the data in any of the formats mentioned in the client’s Accept header. This rarely happens in real life because most web browsers will accept anything signaled by */* in the Accept header of the request. This is a last resort effort, the clients usually signal what content type they want to receive, and they define a priority list, */* us usually with the lowest priority (q=0.5). For example, the client sends the request because there is an img tag in the html, it will signal it to the server that it’s expecting an image in the first place. Accept headers can have various types (accept-encoding, accept-charset, accept-ranges, accept-language, etc.), specifying the characteristics of the data they accept. For example, a web browser may be able to process only HTML or GIF files, so if the web server would not be able to return data in any of these formats “understood” by the client, it will display a 406 Not Acceptable error code.
The reverse can also happen: if a web server doesn’t know the request extension, it may search for another application installed on it to see if that would be able to serve the file. If there isn’t any other application that can serve the file, it will return a 406 Not Acceptable error. The server also will return a 406 when it is not sure about the MIME type of the requested file. This can be quite useful as it might prevent leaking of sensitive information commonly kept in exotic file extensions like .ini, .kdb, .pass, etc.
How to Fix It?
Given that a 406 status code can be a content type negotiation mismatch issue, you need to implement certain changes so that the server has a MIME type associated with the request extension.
If you are running an IIS based web server, you need to make sure that the IIS recognises your extensions. You can add new extension to IIS simply by editing the MIME types. You can add for example *.less and set its MIME type to text/css. This is the most straightforward solution to a 406 Not Acceptable HTTP error returned by the server. If you are running Apache as your webserver, you can add MIME types in the .htaccess file or your VirtualHost configuration. An example for the .less file would be “AddType text/css .less ”.
Alternatively, you can make changes in the Accept header of your browser so it knows the MIME type handled by your server. Making changes to the Accept header can also help, however, it’s a less viable solution than changes made on the server side.
HTTP Error 406 Caused by a mod_security Rule Setting Problem
The other scenario in which you may be met with a 406 status code is when a mod_security rule is enabled on an Apache server. It’s a type of web application firewall (WAF) program enabled by default on the hosting accounts of some web hosting providers. For example, InMotion Hosting has mod_security enabled on all their Apache based hosting accounts to protect web applications from common attacks like XSS or SQL Injections, as these types of security holes can easily creep into web applications. The mod_security continuously scans the server and the incoming request and the outgoing response for violations of rules it has set. If an action that violates the rules set in the mod_security occurs (a violation caused by a site, page or function), the server will send a 406 Not Acceptable error.
How to Fix It?
Disabling mod_security for each of your domains individually or disabling certain rules in Mod_security will help fix the error. If your hosting account comes with cPanel, the easiest way to turn off mod_security is via the modsec Manager plugin. Alternatively, you can use command line in SSH. If you want to disable specific rules or your hosting account does not come with the option to disable/enable mod_security, you need to get in touch with your web hosts’ customer support team to do it for you.
Conclusion
Albeit an infrequent HTTP error, a 406 Not Acceptable error can make an appearance here and there, and when it does happen, it’s most probably caused by a mod_security rule setting problem rather than an Accept header problem. If you’re not comfortable dealing with this issue alone, don’t hesitate to contact the web hosting company your website is hosted at as they can easily get to the root of the problem and fix the error for you.
Hi I can’t download pp in my what’s app because of error 406
I cannot download pp on whatsapp
I can’t upload my dp on whatsapp. Due to error. 406
I also can’t download pp because of 406
Hey my whatsapp no longer wants to set a profile picture. Thanks to error 406.
Hi I can’t set a profile picture on my whatsapp due to 406 error please I nee help
I also hav problem with prof pic on whatsapp due to this 4zero6
I Can Change my whatsapp DP due to Error 406,Please help,
Error 406 is my problem can’t set my profile pic, its really frustrating!!
I can’t change my dp on wassap please help 406 error
Hi I can’t set a profile picture on my whatsapp due to 406 error please I need help.how can we fixed it?
Hi,i can’t set a profile picture on my Whatsapp due to error 406 pls assist.
Hi I can’t load pp on my whatsap because of error 406 please help
Hi evertime I try to set my pp I get the: error 406 msg. It’s frustrating I need help!
How to fix error 406
Hi! I also got an error when tried to upload a picture to my profile on whatsapp: ‘Error 406 while setting profile photo’.
I solved this problem by clearing the cache on whatsapp. Here is what to do:
Go to Settings > Application Setting > Cache and Data – and clear the cache for whatsapp only.
If this doesn’t work, you might try adding and removing Google Account.
Poor internet connection can also cause 406 error while uploading a large image to your profile.
If whatsapp is that important to you and couldn’t solve it with the above mentioned solutions, you might need to factory reset your phone.
Hope this helps some of you!
The error of my blackberry!
All the discussions regarding ‘406 : Not Acceptable’ are considerable by situations of client / server data requests. I have whitelisted the website in Mod_security from server end and it worked for me. You might have to contact your hosting company support or search ‘Whitelisted website in Mod_security’ in google for more information because Mod_security has sensitive role.