HTTP

HTTP 406 Not Acceptable vs 429 Too Many Requests

Both HTTP 406 (Not Acceptable) and 429 (Too Many Requests) belong to the 4xx Client Error category. 406 indicates that the server cannot produce a response matching the Accept headers sent by the client. Meanwhile, 429 means that the user has sent too many requests in a given time (rate limiting). The response should include a Retry-After header.

Description

The server cannot produce a response matching the Accept headers sent by the client.

When You See It

When requesting a content type the server doesn't support (e.g., Accept: application/xml when only JSON is available).

How to Fix

Adjust the Accept header to a format the server supports.

Description

The user has sent too many requests in a given time (rate limiting). The response should include a Retry-After header.

When You See It

When hitting API rate limits or making too many requests too quickly.

How to Fix

Check the Retry-After header. Implement exponential backoff. Consider caching responses.

Key Differences

1.

HTTP 406: The server cannot produce a response matching the Accept headers sent by the client.

2.

HTTP 429: The user has sent too many requests in a given time (rate limiting). The response should include a Retry-After header.

3.

You encounter 406 when when requesting a content type the server doesn't support (e.g., Accept: application/xml when only JSON is available).

4.

You encounter 429 when when hitting API rate limits or making too many requests too quickly.

When to Use Which

For 406 (Not Acceptable): Adjust the Accept header to a format the server supports. For 429 (Too Many Requests): Check the Retry-After header. Implement exponential backoff. Consider caching responses.

Learn More