What 400 means
The server can’t or won’t handle the request because of something it sees as a client mistake: broken syntax, a malformed header, invalid framing, or data it can’t parse.
When servers send it
As the general “your request is wrong” code when nothing more specific (401, 404, 413, 422 and so on) fits. Proxies and servers also send it for oversized cookies or bad headers.
Common causes
- Invalid JSON in the request body (a trailing comma, single quotes).
- A missing required field or query parameter.
- Cookies or headers too large for the server (nginx shows “400 Request Header Or Cookie Too Large”).
- Plain HTTP sent to an HTTPS port (nginx shows “The plain HTTP request was sent to HTTPS port”).
- A malformed URL, such as a bad percent-escape like
%E0%A4%A.
How to fix it as a developer
- Read the response body: well-built APIs say which field is wrong.
- Validate JSON before sending it. The JSON formatter marks the exact problem.
- Check the
Content-Typematches the body, such asapplication/json. - When you’re the server, return a clear error body and use 422 for well-formed data that fails validation, if your API style allows it.
How to fix it as a visitor
- Check the address for typos or odd characters.
- Clear cookies for the site. Oversized or corrupt cookies are a common cause.
- Try a private window, which starts with no cookies or extensions.
Related codes
- 422 Unprocessable Content: The request is well formed, but the data in it doesn’t make sense, such as failing validation.
- 431 Request Header Fields Too Large: The request headers are too big, very often because of too many or too large cookies.
- 413 Content Too Large: The request body, such as an upload, is bigger than the server will accept.
- 415 Unsupported Media Type: The server doesn’t accept the format of the request body, usually because of the Content-Type header.
- 401 Unauthorized: You need to log in, or the credentials you sent are missing, wrong or expired.
Where it’s defined
400 Bad Request is defined in RFC 9110, section 15.5.1. It’s a 4xx code, the client error class: something is wrong with the request, so sending it again unchanged won’t help.
Other 4xx codes
401 Unauthorized · 402 Payment Required · 403 Forbidden · 404 Not Found · 405 Method Not Allowed · 406 Not Acceptable · 408 Request Timeout · 409 Conflict · 410 Gone · 413 Content Too Large · 414 URI Too Long · 415 Unsupported Media Type · 418 I’m a teapot · 422 Unprocessable Content · 429 Too Many Requests · 431 Request Header Fields Too Large · 451 Unavailable For Legal Reasons · 499 Client Closed Request
Or search them all in the HTTP status code list.
Questions people ask
What does HTTP 400 Bad Request mean?
Should I use 400 or 422 for validation errors?
Why do I get “400 Request Header Or Cookie Too Large”?
large_client_header_buffers.