Common causes
- The JSON body is invalid, for example with a trailing comma, or it was sent as
[object Object]becauseJSON.stringifywas forgotten. - The
Content-Typeheader doesn't match the body, such as JSON sent withoutContent-Type: application/json. - A required field or query parameter is missing, or has the wrong type.
- The URL contains characters that weren't encoded, such as spaces or
#in a query value. - The cookies or headers are too large for the server.
"Request Header Or Cookie Too Large"
nginx shows 400 Bad Request: Request Header Or Cookie Too Large when the cookies for a site grow past its header buffer, often after many logins or analytics cookies. As a visitor, clear the cookies for that site. As the owner, keep cookies small, or raise the limit:
# nginx: allow larger request headers
large_client_header_buffers 4 32k;Send JSON correctly
Then read the response body: most APIs say which field was wrong in their 400 response.
await fetch("/api/users", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "Ada" }), // not the object itself
});Frequently asked questions
What is the difference between 400 and 422?
Many APIs use 400 for requests they can't parse, such as invalid JSON, and 422 Unprocessable Content for well-formed requests whose values fail validation. Others use 400 for both.
Why do I get 400 in the browser but not in Postman?
Compare the requests: the browser may send different headers, more cookies, or a body that wasn't stringified. Copy the browser request as curl from the network tab and compare it with Postman's.
Is a 400 error a server problem?
The status says the client sent something wrong. But if every user gets it on a page that used to work, the site may have changed what it expects, or set cookies that are now too large.
More http status code lookup guides
- 502 Bad Gateway: What It Means and How to Fix It
- 504 Gateway Timeout: Causes and Fixes
- 429 Too Many Requests: Meaning, Retry-After and Fixes
- 403 Forbidden: Meaning, Causes and How to Fix It
- 401 Unauthorized: What It Means and How to Fix It
- 500 Internal Server Error: Causes and How to Fix It
- 503 Service Unavailable: Causes and Fixes
- 404 Not Found: What It Means and How to Fix It
- 301 Moved Permanently: Meaning, SEO and Examples
- 302 Found: Temporary Redirects Explained
- 408 Request Timeout: Causes and How to Fix It