# HTTP 406 Not Acceptable — Meaning, Causes & Fixes

> The server can't produce a response matching the request's Accept headers.

406 is failed content negotiation. The client said which formats, languages or encodings it accepts (`Accept`, `Accept-Language`, `Accept-Encoding`), and the server has nothing that fits. Most servers ignore an unsatisfiable Accept header and send their default instead, so a 406 usually comes from a strict API framework or a firewall.

- Class: 4xx Client Error
- Retry: No — change the request first
- Cacheable by default: no
- Defined in: [RFC 9110 §15.5.7 — 406 Not Acceptable](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.7)

## Example response

```http
HTTP/1.1 406 Not Acceptable
Content-Type: application/json
Content-Length: 26

{"error":"Not Acceptable"}
```

## Common causes

- Requesting `Accept: application/xml` from a JSON-only API.
- A client library sending an unusually narrow Accept header.
- Some WAFs, notably mod_security, use 406 to block suspicious requests.

## How to fix it

1. Send `Accept: application/json`, or `*/*`.
2. On the server, consider falling back to a default representation instead of failing.
3. If mod_security sent it, its audit log names the rule that fired.

## Send a 406 from your server

### Express

```
res.status(406).json({ error: "Not Acceptable" });
```

### Next.js route handler

```
return Response.json({ error: "Not Acceptable" }, { status: 406 });
```

### Flask

```
return {"error": "Not Acceptable"}, 406
```

### Go net/http

```
http.Error(w, "Not Acceptable", http.StatusNotAcceptable)
```

### nginx

```
return 406;
```

## FAQ

### 406 vs 415?

406 is about the response format the client will accept (Accept). 415 is about the request format the client sent (Content-Type).

## Related status codes

- [415 Unsupported Media Type](https://www.devkult.com/http/415.md)
- [300 Multiple Choices](https://www.devkult.com/http/300.md)
- [400 Bad Request](https://www.devkult.com/http/400.md)

Open the interactive page: https://www.devkult.com/http/406