HTTP 400 Bad Request vs 431 Request Header Fields Too Large
Both HTTP 400 (Bad Request) and 431 (Request Header Fields Too Large) belong to the 4xx Client Error category. 400 indicates that the server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing. Meanwhile, 431 means that the server refuses to process the request because an individual header field or all headers collectively are too large.
Description
The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
When You See It
When sending malformed JSON, missing required fields, or invalid query parameters.
How to Fix
Check the request body format, validate all required fields, and ensure proper encoding.
Description
The server refuses to process the request because an individual header field or all headers collectively are too large.
When You See It
When cookies accumulate to an excessive size, or a single header (like Authorization) is too long.
How to Fix
Reduce header sizes. Clear excessive cookies. Use shorter tokens.
Key Differences
HTTP 400: The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.
HTTP 431: The server refuses to process the request because an individual header field or all headers collectively are too large.
You encounter 400 when when sending malformed JSON, missing required fields, or invalid query parameters.
You encounter 431 when when cookies accumulate to an excessive size, or a single header (like Authorization) is too long.
When to Use Which
For 400 (Bad Request): Check the request body format, validate all required fields, and ensure proper encoding. For 431 (Request Header Fields Too Large): Reduce header sizes. Clear excessive cookies. Use shorter tokens.