HTTP error reference
400 Bad Request
A 400 Bad Request means the server could not understand the request as it was sent: something about the address, headers, cookies or body was malformed. The server is fine; the request was not.
If you are visiting the site
Clear the cookies for that one site and try again. Oversized or corrupted cookies are the most common reason a normal visitor sees a 400. Also check the address for stray characters.
Common causes
Cookies or headers too large
Many or large cookies push the request headers over the server’s limit. Nginx shows “Request Header Or Cookie Too Large”; Apache limits each header line to 8,190 bytes by default.
A malformed address
Invalid characters, broken percent-encoding or an extremely long query string.
Plain HTTP sent to the HTTPS port
Nginx answers “The plain HTTP request was sent to HTTPS port” when something connects to port 443 without TLS, often a misconfigured proxy or health check.
An invalid API body
JSON that does not parse, a missing required field, or a Content-Type header that does not match the body.
How to fix it
Nginx
- If large cookies are legitimate, raise large_client_header_buffers (the default is 4 buffers of 8k). Better still, find out why the cookies grew so large.
- Make sure proxies and health checks use https:// when they connect to port 443.
Apache
- LimitRequestFieldSize controls the maximum size of one header line; raise it only if you need to.
APIs
- Validate the body against the API’s documentation and read the response body: most APIs say which field they rejected.
Quick checklist
Check the request URL, encoding and body.
Compare a failing request with a minimal request.
Inspect validation or proxy logs for the same timestamp.
Questions about 400 errors
Why does clearing cookies fix a 400?
Because the cookies were too large or corrupted. Clearing them shrinks the request back under the server’s limit.
Is a 400 the server’s fault?
Usually not. It means the request was malformed, though a server limit that is set too low can also cause it.