Anti-Bot & Web Protection

What Is the 406 Not Acceptable Error and How Do We Fix It (Accept Header + cPanel .htaccess Method)

When you hit a 406 Not Acceptable error, it can feel like the website is “rejecting” you for no clear reason. We’ve run into it while testing APIs, submitting forms, and even just opening a page after a server change. You do everything right, but the server still says “No.”

What’s really going on is usually a mismatch between what your browser or app asks for and what the server is willing or able to send back. Behind the scenes, your browser sends an Accept header, which is basically a list of file types it can handle, like HTML or JSON. If the server can’t match that request, it returns 406.

The good news is we can practically fix this. First, we confirm whether it’s a response-format issue (Accept header). Then we check if a security layer (often ModSecurity) is blocking the request. After that, we apply the right fix without guessing.

What does the 406 Not Acceptable error mean?

A 406 Not Acceptable error means the server understood the request, but it can’t respond in any format your client said it can accept. In plain terms, your browser or API tool is saying, “Send me JSON,” but the server is saying, “I can only send HTML,” or “I’m not sending anything that matches your list.”

What Is the 406 Not Acceptable Error and How Do We Fix It

Why does the Accept header matter for a 406 error?

The Accept header matters because it tells the server which response formats your client will accept.

Let’s break this down in a simple way:

  • You open a web page or call an API.
  • Your device sends a request.
  • That request includes headers.
  • One key header is Accept.
  • If the server can’t produce a matching response format, it may return 406.

Example Accept headers you might see:

  • Accept: text/html
  • Accept: application/json
  • Accept: application/xml
  • Accept: */* (this means “we accept anything”)

A common mistake is making Accept too strict during testing.

What is content negotiation and how does it connect to 406?

Content negotiation is the server picking a response format based on what the client requests, and 406 happens when there’s no match.

In real-world usage, this shows up when:

  • A browser expects HTML.
  • An API client expects JSON.
  • A legacy integration expects XML.

If the client asks for only one format and the server doesn’t support it, the negotiation fails and 406 appears.

What are the most common causes of 406 errors?

Most 406 errors come from either a format mismatch (Accept header) or a security rule blocking the request.

Here are the causes we see most often:

  1. The client requests JSON but the endpoint returns only HTML
    • For example, a browser page is called like an API.
  2. The client requests XML but the server only outputs JSON
    • This happens a lot with older partners and older tools.
  3. The server has no formatter or serializer for the requested type
    • For example, XML output is not enabled.
  4. ModSecurity (or another firewall rule) blocks a request
    • This often happens during form submits and logins.
  5. A plugin, theme, or rewrite rule triggers a false security hit
    • For example, a contact form message includes special characters that look “suspicious.”

How can we quickly tell if it’s Accept header vs security filtering?

We can usually tell by changing the Accept header and seeing if the result changes.

Here’s a simple comparison table we use when debugging:

❮ Swipe table left/right ❯
What you noticeMore likely Accept header issueMore likely security block
Happens mainly in Postman, curl, scriptsYesSometimes
Happens when submitting forms or logging inSometimesYes
Changing Accept to */* fixes itYesNo
Only certain words or symbols trigger itNoYes
Happens right after hosting/security updatesSometimesYes

It might be helpful to test both possibilities before you change server settings.

What is the fastest client-side fix for a 406 error?

The fastest fix is to set an Accept header the server can actually match.

Try these quick options:

  • If you want JSON:
    Accept: application/json
  • If you are testing and don’t care about format:
    Accept: */*
  • If you can accept multiple types:
    Accept: application/json, text/html, */*

How can we test the fix with a simple request?

We can test by making one clean request with a broad Accept header and then narrowing it.

A simple testing order:

  1. First try Accept: */*
  2. Then try the format you really want (like JSON)
  3. Finally confirm the server returns the correct Content-Type

How do we fix a 406 Not Acceptable error using cPanel and .htaccess?

We fix many server-side 406 cases by updating .htaccess to reduce ModSecurity blocking, especially when valid requests are being flagged.

Let’s be clear: this method is mainly for cases where security rules are returning 406, not when an API truly can’t produce a requested format.

Why does this happen in hosting environments?

This happens because some shared hosting servers use ModSecurity rules that block certain request patterns and return 406.

In many cases, you did nothing “wrong.” A normal form post or URL can trip a rule, and the server blocks it.

How do we fix 406 or Not Acceptable using .htaccess from cPanel?

We fix it by editing the .htaccess file in cPanel and adding a small block of code that disables certain ModSecurity checks.

Before we start, a quick safety note from experience: we should always copy the existing .htaccess content into a safe text file first. That way, if something breaks, we can restore it fast.

Step 1: Open File Manager in cPanel

Open File Manager in cPanel

We open File Manager by logging into cPanel and selecting the File Manager icon under the Files section.

  • Log in to cPanel
  • Search for File Manager
  • Open it

Step 2: Where do we find the right folder?

We usually find the website files inside public_html.

  • Click public_html
  • On some hosts, you may also see a home directory first
  • The goal is to reach the folder where your site files live

Step 3: How do we edit the .htaccess file?

How do we edit the .htaccess file

We edit .htaccess by locating it in public_html, right-clicking it, and choosing Edit.

If you don’t see it:

  • Enable “Show Hidden Files” in File Manager settings
  • .htaccess is hidden on many systems

Step 4: What do we do when the encoding popup appears?

We continue by clicking the Edit button on the popup so the file opens in the editor.

You might see an option related to encoding. In most cases, we can proceed with the default.

Step 5: What code do we add to fix 406 in .htaccess?

We add a small ModSecurity block to the .htaccess file.

Copy and paste this code into the file (often at the top or bottom, depending on your rules):

<IfModule mod_security.c>
  SecFilterEngineOff
  SecFilterScanPOSTOff
</IfModule>

What this means is we’re telling the server to stop scanning certain POST requests using those ModSecurity settings.

A common failure mode is placing this inside another broken block. So keep the formatting clean and separate.

Step 6: How do we save changes?

How do we save changes

We save by clicking the Save Changes button in the top-right of the editor.

After that:

  • Refresh your website
  • Retry the action that caused the error (login, form submit, API call)
  • Now, back to your site and reload.

Final check: How do we confirm the 406 error is gone?

We confirm it’s fixed when the same request that failed before now returns a normal page or a normal API response.

If it still fails, the next step is to check server logs or ask hosting support which rule is blocking it. In many cases, disabling only one specific rule is safer than disabling scanning broadly.

What are safer alternatives to disabling ModSecurity in .htaccess?

A safer alternative is to disable only the specific rule that triggers false positives instead of turning off scanning for everything.

In many situations, hosting support can:

  • identify the exact rule ID that triggered the block
  • whitelist your endpoint or parameter
  • reduce the chance of future security issues

From our perspective, this is often the best long-term path, especially for stores, membership sites, and payment forms.

How do we prevent 406 errors from coming back?

We prevent 406 errors by keeping response formats predictable and avoiding overly strict Accept headers or risky security triggers.

Here are practical prevention steps we actually use:

  1. Keep API responses consistent (JSON-only or clearly documented formats).
  2. Avoid forcing rare Accept types unless the server supports them.
  3. Test forms with real messages users write (not only short test text).
  4. Review security settings after installing plugins and themes.
  5. Keep backups of .htaccess before changing rules.

FAQ About 406 Not Acceptable Error

Is a 406 error usually my fault?

No, it’s often caused by a mismatch between what your client asks for and what the server is configured to return.

Can a browser cause a 406 error?

Yes, browsers send Accept headers automatically, and unusual browser settings or extensions can trigger 406.

Does a 406 error mean the page does not exist?

No, it means the server cannot return the page in an acceptable format, not that the page is missing.

Can ModSecurity trigger a 406 error?

Yes, ModSecurity can block a request and return 406 when it thinks the request matches a security rule.

Will editing .htaccess always fix a 406 error?

No, it helps mainly when security rules cause the block, but it won’t fix a true response-format mismatch in an API.

Should we disable ModSecurity for every site?

No, disabling security broadly increases risk, so it’s better to disable only the specific rule when possible.

Conclusion

A 406 Not Acceptable error usually means the server can’t return a response in a format your client accepts, or a security rule is blocking the request. Once we test which one it is, the fix becomes straightforward.

If you’re seeing 406 in API testing, start by adjusting the Accept header. If you’re seeing it on form submits or admin actions, it may be ModSecurity, and the cPanel .htaccess method can help.

If you want, tell us what platform you’re using (WordPress, Laravel, Node, ASP.NET, Spring) and where the error happens (page load, login, form submit, API call). We’ll map it to the most likely cause and the cleanest fix.

Data Prixa

Data Prixa

Dataprixa is an independent editorial platform focused on data infrastructure and security insights. The content published under this author explores web scraping, data collection, proxy networks, and cybersecurity technologies with an emphasis on clarity, ethical practices, and long-term relevance. Articles are written to support developers, researchers, and modern businesses in understanding data-driven systems and secure infrastructure.