HTTP status code lookup

400 Bad Request: Causes and Fixes (Including Cookie Too Large)

A 400 Bad Request means the server couldn't or wouldn't process the request because something about the request itself is wrong: the body, the headers or the URL. Sending the same request again gives the same error until it's fixed.

400

Bad Request

The server can't process the request because of a client error, such as malformed syntax or invalid data.

Look up any other status code →

Common causes

  • The JSON body is invalid, for example with a trailing comma, or it was sent as [object Object] because JSON.stringify was forgotten.
  • The Content-Type header doesn't match the body, such as JSON sent without Content-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

Open the full http status code lookup →

From the blog