What 406 Not Acceptable Means
Clients state which formats they accept in headers: Accept for the content type, Accept-Language, and Accept-Encoding. Choosing a response that fits is called content negotiation, and 406 means nothing fits. Most servers ignore a preference they cannot meet and send their default, so a real 406 from negotiation is rare. On web servers it far more often comes from a web application firewall set up to answer with this code. Other client errors are in HTTP status codes.
What a Visitor Can Try
- Change what you sent: form text that looks like code, such as SQL keywords or HTML tags, can trigger a firewall rule. Rephrase it and send it again.
- Report it: tell the site owner the time, the page, and what you entered. That is enough to find the rule.
Check Content Negotiation First
curl -i https://example.com/api/items
curl -i -H "Accept: application/xml" https://example.com/api/itemsIf only one Accept value fails, the application refuses a format it cannot produce, which is correct: the client should ask for a supported type. In Apache, the MultiViews option can also answer 406 when none of several file variants matches. Remove it from the Options line if you do not use variants.
The Usual Cause: a Firewall Rule
ModSecurity, with a rule set such as the OWASP Core Rule Set, checks each request for attack patterns and denies a match with the status its configuration sets; many installations use 406 instead of 403. Signs of this case: the error depends on what was submitted, not on the address, and hits POST requests with rich text or code samples. ModSecurity runs as an Apache module, or in Nginx through a connector module. Check whether it is loaded in Apache on Ubuntu and Debian:
sudo apache2ctl -M | grep -i securityOn AlmaLinux and Rocky Linux the apachectl wrapper does not pass -M on, so ask httpd directly. For Nginx, search the configuration:
sudo httpd -M | grep -i security
sudo grep -rn -i "modsecurity on" /etc/nginx/Find the Rule That Matched
Each block writes a line to the web server's error log with the word ModSecurity, the status code, and the rule id in a field such as [id "942100"]. Use the line for your system:
sudo grep -i modsecurity /var/log/apache2/error.log | tail -5
sudo grep -i modsecurity /var/log/httpd/error_log | tail -5
sudo grep -i modsecurity /var/log/nginx/error.log | tail -5Note the rule id, its message, the address, and the part of the request that matched, for example a form field named comment. For the full request, open the audit log. Its path is set by the SecAuditLog directive; common places are /var/log/apache2/modsec_
Correct the Request or Add a Narrow Exception
First decide whether the request was harmful; real attacks should stay blocked. For a false positive, change as little as possible. If your own code sends something odd, such as an unencoded parameter, correct the code. If a legitimate field, such as a rich text editor, trips one rule, exclude that field from that rule only:
SecRuleUpdateTargetById 942100 "!ARGS:comment"In Apache you can also remove one rule for one address only:
<LocationMatch "^/admin/save-post$">
SecRuleRemoveById 942100
</LocationMatch>Use the id from your own log, place the exception after the rule set is loaded (the Core Rule Set ships an exclusion file meant for such lines), test with sudo apachectl configtest or sudo nginx -t, and reload the web server.
Why Not Switch the Firewall Off
Turning ModSecurity off, or setting the whole engine to log without blocking, makes the 406 disappear and removes the protection from every page on the server. One misfiring rule on one form does not justify that. A narrow exception keeps every other rule working. The same applies to an .htaccess file that disables the module for a whole site; see the .htaccess file for how overrides are scoped.
Confirm the Fix
Repeat the request that failed, with the same kind of data:
curl -i -X POST -d "comment=Select the best option from the list" https://example.com/admin/save-postIt should pass, and the error log should show no new ModSecurity line for that rule and address. Keep watching the log for a few days: blocks on other pages show that the remaining rules still work.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations