Home » Wiki » How to Fix HTTP 406 Not Acceptable Error?

How to Fix HTTP 406 Not Acceptable Error?

by | Last updated Apr 25, 2025 | SSL Errors

Fix HTTP 406 Not Acceptable Error
When a web server cannot provide content that matches the client’s accepted content types, the HTTP 406 Not Acceptable Error occurs. Check your Accept headers in the HTTP request and make sure they match the content types the server can deliver to fix this error. The most common solutions are updating your browser settings, clearing cache and cookies and verifying API request headers.

The developers can resolve this by implementing proper content negotiation on the server side and ensuring correct MIME type configurations. If you are a website visitor, switching browsers or disabling browser extensions usually solves the problem. The most 406 errors can be fixed in minutes with these basic troubleshooting steps.

What is the HTTP 406 Not Acceptable Error?

The HTTP 406 Not Acceptable Error occurs when a web server cannot deliver content that matches the client’s accepted content types. This error appears when your browser requests specific content formats through the Accept header, but the server cannot provide those formats. For example, if your browser asks for JSON data, but the server can only send XML, you’ll see a 406 error.

Common causes include incorrect Accept headers, server misconfiguration, or content negotiation issues. To fix this, check your request headers, update content type settings, or modify server configurations to support the requested format.

Common Causes of HTTP 406 Errors

Before fixing the issue, identify the root cause:

Cause

Description

Incorrect Accept Header

Client requests an unsupported format (e.g., Accept: text/html for a JSON-only API).

Server Misconfiguration

Web server (Apache/Nginx) lacks proper MIME type support.

Framework Restrictions

Backend frameworks (Django, Flask) enforce strict content policies.

Proxy/CDN Issues

Cloudflare or AWS might alter headers, causing negotiation failures.

Broken API Versioning

An API v2 endpoint might reject v1-style requests.

How to Fix HTTP 406 Not Acceptable Error (A Step-by-Step Solutions)

  • Check the Accept Header (Client-Side)
  • Configure Server MIME Types
  • Debug Framework-Specific Issues
  • Test API with Postman/Swagger

Fix 1: Check the Accept Header (Client-Side)

The client (browser, API tool) must request a supported format.

Steps:

Inspect Headers (Chrome DevTools):

  • Open Network Tab→ Check the Accept
  • Example:
Accept: application/json

Test with Curl/Postman:

curl -H "Accept: application/json" https://api.example.com/data
  • If the server expects XML, modify the header:
curl -H "Accept: application/xml" https://api.example.com/data

Fix 2: Configure Server MIME Types

If the server doesn’t support the requested format, adjust its MIME types.

For Apache (.htaccess)

AddType application/json .json
AddType application/xml .xml

For Nginx (mime.types)

Ensure JSON/XML are listed:

Restart the server afterward.

Fix 3: Debug Framework-Specific Issues

Django Fix

If Django returns 406, check:

  • settings.py:
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': [
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
    ]
}
  • View-Level Overrides:
@api_view(['GET'])
@renderer_classes([JSONRenderer])
def my_api(request):
    return Response({"data": "example"})

WordPress Fix

  • Disable Plugins: Some plugins (security, caching) may alter headers.
  • Check .htaccess: Ensure no rewrite rules block valid formats.

Fix 4: Test API with Postman/Swagger

  • Use Postman to manually set headers.
  • Verify Swagger/OpenAPI docs for supported formats.

4. Advanced Troubleshooting to Resolve HTTP 406 Not Acceptable Error?

Check Server Logs

  • Apache: tail -f /var/log/apache2/error.log
  • Nginx: tail -f /var/log/nginx/error.log
Look for entries like:
"406 Not Acceptable: Supported formats: json, xml"

Proxy/CDN Conflicts

  • Disable Cloudflare “Rocket Loader” or AWS API Gateway
  • Test directly on the origin server.

How to Prevent HTTP 406 Not Acceptable Error in Future

Prevention Method

Action

Set Default Formats

Ensure APIs default to JSON if no Accept header is sent.

Document API Requirements

Clearly state supported formats (e.g., Accept: application/json).

Use Content Negotiation Middleware

Frameworks like Express.js can auto-negotiate formats.

Monitor with API Gateways

Tools like Kong or Apigee can enforce format rules.

How 406 Differs From Other 4xx Errors

Status Code Meaning Key Difference
400 Bad Request Malformed syntax General client error
403 Forbidden Permission denied Authentication issue
404 Not Found Resource missing URL doesn’t exist
406 Not Acceptable Format mismatch Content negotiation failure

Final Thoughts

The HTTP 406 “Not Acceptable” error occurs when a server cannot fulfill a client’s requested content format. To fix it, verify the Accept header matches supported formats (JSON, XML, etc.), check server MIME type configurations, and debug framework-specific settings (Django, WordPress). Use tools like cURL, Postman, or browser DevTools to test requests.

Prevent future errors by documenting API requirements and implementing proper content negotiation. With these steps, you can resolve 406 errors efficiently and ensure seamless client-server communication. Still stuck? Consult server logs for detailed insights.

Frequently Asked Questions (FAQs)

What causes a 406 Not Acceptable error?

The HTTP 406 error occurs when a web server cannot generate content that matches the client’s accepted content types. The client browser sends specific content format requirements in its request headers, but the server cannot fulfill these requirements.

How do I fix 406 Not Acceptable in REST API?

Clear your browser cache and cookies first. Check and modify your Accept header to include common content types like “application/json” or “text/plain”. Verify your API endpoint’s content-type matches the Accept header in your request.

Is HTTP 406 a client or server error?

HTTP 406 is a client-side error. The error indicates that the client’s request headers specify content requirements that the server cannot fulfill. The server understands the request but cannot generate the requested content format.

How do I fix 406 Not Acceptable in Chrome?

Reset Chrome’s browser settings to default values. Clear the browser cache and cookies completely. Disable browser extensions temporarily. Check if your browser accepts common content types in its request headers.

How do I fix HTTP 406 in WordPress?

Update your WordPress installation and all plugins. Check your .htaccess file for incorrect content negotiation rules. Verify your server’s content-type configuration. Reset your permalinks structure in WordPress settings.

What is the difference between 406 and 415 status codes?

Error 406 means the server cannot generate content matching the client’s accepted formats. Error 415 indicates the server refuses to accept the request payload format. Both relate to content type issues but from different perspectives.

Priya Mervana

Priya Mervana

Verified Badge Verified Web Security Experts

Priya Mervana is working at SSLInsights.com as a web security expert with over 10 years of experience writing about encryption, SSL certificates, and online privacy. She aims to make complex security topics easily understandable for everyday internet users.

Stay Secure with SSLInsights!

Subscribe to get the latest insights on SSL security, website protection tips, and exclusive updates.

✅ Expert SSL guides
✅ Security alerts & updates
✅ Exclusive offers