whatsapp

406 Not Acceptable: What It Means and How to Resolve It

406 not acceptable

When you use an online service or visit a website, your browser and the server behind that website need to understand each other. Sometimes, they don’t understand each other, and it shows up through an error message like “406 Not Acceptable.” 

While errors like 200 OK or 404 Not Found are familiar status codes, the 406 error can be more confusing. Resolving this error may seem like a difficult task. But you don’t have to worry about that.  

In this blog, we’ll understand the basics of the 406 error, what causes this error, and how to solve it. Let’s dive straight into it!  

What Does “406 Not Acceptable” Mean?

The 406 error code is an HTTP status code that means not acceptable. It occurs when the server cannot generate a response based on the client’s request, as mentioned in the request headers, particularly the “Accept” header. This usually happens when the client requests a specific format or language that the server cannot provide.   

In short, a 406 error indicates that the server can’t provide a response matching the client’s specified requirements, often due to content negotiation issues. 

406 Not Acceptable

What are the Causes of a 406 Error?

The 406 Not Acceptable error can occur due to mismatch between what your browser or app (client) is asking for and what the website (server) can give. This problem can come on either client side or server side of the connection.  

Client-Side Causes

  1. Incorrect Accept Header: The client may request a content type that the server doesn’t support. For example, asking for XML when the server only provides JSON.
  1. Unusual Defaults from Tools or Browsers: Some browsers or API tools send strict or unusual Accept headers by default. These strict settings can stop the server from sending a proper response, even if the server can actually handle other formats. 
  1. Typos or Malformed Headers: A simple error in the Accept header, such as a typo or formatting mistake, can make the request invalid. If the server can’t understand the header, it may return a 406 error.  
  1. Security Software or Extensions: Sometimes, browser extensions, antivirus tools, proxies, or firewalls that alter or block HTTP headers can be the cause of this error. These tools might strip out or change the Accept header, leading to unexpected errors. 

Server Side Causes

  1. Server Configuration Issues: The web server (e.g., Apache, Nginx). The server isn’t set up to provide the type of content your browser or app is asking for. If the requested format isn’t supported or properly configured, the server won’t be able to respond.  
  1. Application Logic Errors: The backend application might try to respond in a way it can’t actually support or fail to handle content negotiation properly, resulting in a rejection of the request.  
  1. Missing Content Format or Conversion Ability: Even if the request is valid, the server may not have the requested content available in that format, or it might not have the ability to convert data into the format the client is asking for.  
  1. Security Rules or Web Application Firewalls (WAFs): Some servers use security tools like ModSecurity to block requests that appear suspicious. If an Accept header is too complex, specific, or unusual, it may be blocked, even if the request is otherwise valid.  

How to Resolve 406 Not Acceptable Error?

Now that you know why this 406 error happens, let’s see how to fix this error. To solve this error, it’s best to work through this issue step by step, starting with the most common causes. It’s usually easiest and quickest to begin by checking the client side before moving on to the server.  

Fixing the Client Side

  1. Review What Your Browser or App Is Requesting: Look into the content type that your browser or app is asking for. You want to make sure it matches something the server is able to provide.  
  1. Try Requesting a More General Type of Response: If you’re unsure what format is supported, you can try to request more general or commonly used types of content, such as standard web pages or plain text. If the server responds, you’ll have a better idea of what it supports.  
  1. Remove Strict Preferences for Content Type: Sometimes, not being too specific about what type of content you want allows the server to reply with its default format, which is often acceptable.  
  1. Clear Your Browser’s Cache and Cookies: Old or damaged data stored in your browser may interfere with how it sends requests to the server. Clear the data first and then try your request again. 
  1. Try a Different Browser or Application: If the problem goes away when using a different browser or tool, the issue likely comes from the settings or behaviour of the one you were using before. 

Fixing the Server Side

  1. Check the Server’s Error Logs: Logs often contain detailed messages about what went wrong, including why a response couldn’t be sent.  
  1. Make Sure the Server Supports the Requested Format: The server should be able to generate and send the type of content that your browser or app is asking for.  
  1. Review the Website’s Software and Settings: The system that runs the website or service should clearly set the content type it can provide. It should also be able to convert information into the requested format, if needed.  
  1. Check Security Tools: If the server is using a Web Application Firewall or similar security tool, it may be blocking certain kinds of requests. These systems should be reviewed and adjusted if they’re being too strict.  

Final Words

The 406 Not Acceptable error happens when the client and server can’t agree on what type of content should be sent. Most of the time, the issue can be resolved by adjusting how the client makes the request, such as being less specific about content types.  

If that doesn’t help, then checking the server’s setup and logs will help identify the issue. Once both sides are aligned, communication can continue without errors. Now that you know what a 406 error means, its causes, and how to fix it, you can easily avoid this issue next time. 

Knotsync