400 vs 431: Bad Request vs Request Header Fields Too Large
400 and 431 can look similar in logs, but they tell clients, crawlers, and API consumers different things.
| Aspect | 400 | 431 |
|---|---|---|
| Meaning | Bad Request describes how the server processed the request and what the client should do next. | Request Header Fields Too Large describes how the server processed the request and what the client should do next. |
| Typical use case | HTTP 400 Bad Request indicates a client errors response outcome. | HTTP 431 Request Header Fields Too Large indicates a client errors response outcome. |
| Caching/client behavior | Check cache headers and downstream behavior for 400. | Check cache headers and downstream behavior for 431. |
| SEO implications | Search crawlers interpret 400 according to client-errors semantics. | Search crawlers interpret 431 according to client-errors semantics. |
| API/backend impact | API clients may branch logic specifically on 400. | API clients may branch logic specifically on 431. |
When to use one vs the other
Use 400 when the response should communicate bad request behavior; use 431 when request header fields too large is the accurate protocol signal.
A frequent mistake is swapping 400 and 431 for convenience; that causes client retry bugs, incorrect cache signals, and misleading monitoring data.
Decision summary: if user agents should receive the Bad Request signal, return 400; if they should receive Request Header Fields Too Large, return 431.
FAQ
What is the biggest difference between 400 and 431?
400 communicates Bad Request, while 431 communicates Request Header Fields Too Large. Choosing the right one keeps clients and intermediaries predictable.
Do 400 and 431 have SEO or caching impact?
Yes. Search engines and caches interpret status classes differently. Use each code according to its semantics to avoid accidental indexing, stale responses, or crawl inefficiency.
Can APIs safely return 400 instead of 431?
Only when it matches contract semantics. API clients often branch logic by exact code, so swapping them can break retries, auth handling, or user-facing errors.
Related guides: 400 Bad Request ยท 431 Request Header Fields Too Large