"Getting a 406 Error Code - What’s Causing It and How Do I Fix It?"
Ugh, just ran into the 406 error code on my site and it’s driving me nuts! Anyone else dealt with this?
From what I’ve gathered, it’s all about the server not liking what my browser is asking for. Like, it’s picky about formats or headers or something.
Tried a few things:
- Checked my .htaccess file (no weird rules?)
- Made sure my Accept headers are sane
- Cleared cache like a maniac
Still no luck. Anyone got a magic fix or is this just a server-side tantrum?
Also, why’s it called "Not Acceptable"? So dramatic. 😂
Drop your tips below!
Hey! Had the same 406 error code issue last week. Turns out my server was super strict about content negotiation.
Try adding this to your .htaccess:
`Header set Accept "application/json, text/html"`
Also, check if your API endpoints are expecting a specific format. Sometimes the server just won’t budge unless you send EXACTLY what it wants.
For debugging, Postman (postman.com) is a lifesaver—you can tweak headers and see what sticks.
Good luck!
lol yeah the "Not Acceptable" name is extra. 😂
But for real, the 406 error code usually pops up when your server’s like "nah, I don’t like how you’re asking."
Did you check the MIME types? If your server’s configured to only accept, say, JSON but your request is sending XML, it’ll throw a fit.
Also, maybe try disabling mod_security temporarily? Sometimes it blocks stuff for no reason.
Ugh, 406 errors are the worst. Had this happen when my client’s CMS was forcing weird headers.
Two things that worked for me:
1. Forcing the Accept header in PHP: `header('Accept: application/json');`
2. Using curl to test the request directly—sometimes browsers add junk headers.
If you’re on WordPress, the "Rest API" plugin can help debug too.
406 error code? Sounds like your server’s being a diva.
Quick fix: Try sending a blank Accept header. Sounds weird, but some servers default to a sane format if you don’t specify.
Also, if you’re using Cloudflare, turn off "Rocket Loader"—it messes with headers sometimes.
For tools, check out "HTTP Toolkit" (httptoolkit.tech). Lets you see exactly what’s being sent/received.
Yo, thanks for all the tips! Tried the .htaccess tweak and it kinda worked? But now I’m getting a 406 error code ONLY on mobile.
Weird, right? Maybe it’s a user-agent thing? Gonna test with Postman like someone suggested.
Also, nginx config tip was gold—didn’t even think about that.
Anyone else run into mobile-specific 406 issues?
Not gonna lie, the 406 error code had me stuck for DAYS.
Finally figured out it was my nginx config—had to add `default_type application/json;` to stop the tantrum.
Also, if you’re using Axios or fetch(), double-check the `headers: { Accept: "*/*" }` bit. Some servers hate the wildcard.
Classic 406 drama! 😅
One sneaky thing: if you’re uploading files, check the `enctype` in your form. Had a case where the server rejected multipart/form-data unless it was spelled out perfectly.
Oh, and if you’re on Apache, `curl -I [your-url]` can show you what headers the server’s expecting.
---