Tech

Explainer

Updated

What does the HTTP 400 status code mean?

Key facts

RFC 9110 gives malformed request syntax, invalid request message framing and deceptive request routing as examples of the client errors behind a 400.

The HTTP 400 status code, named Bad Request, means the server cannot or will not process a request because of something it perceives to be a client error, according to RFC 9110, the IETF standard that defines HTTP semantics.

What RFC 9110 says about 400 Bad Request

Section 15.5.1 of RFC 9110 defines the code in one sentence: "The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)."

The examples in that definition are:

  • malformed request syntax
  • invalid request message framing
  • deceptive request routing

What the 4xx class means

RFC 9110 says the first digit of a status code defines its class, and that the 4xx (Client Error) class indicates that the client seems to have erred. The same standard says that, except when responding to a HEAD request, the server should send a representation explaining the error and whether it is temporary or permanent, and that user agents should display that representation to the user.

Code 400 is also the fallback for the class. Under RFC 9110, a client must understand the class of any status code and treat an unrecognized code as the x00 code of its class, so a client that receives an unrecognized 471 treats the response as if it were a 400 (Bad Request).

How 400 differs from 401, 403, 404 and 422

Each of these codes has its own definition in Section 15.5 of RFC 9110:

CodeNameWhat RFC 9110 says it indicates
400Bad RequestThe server cannot or will not process the request because of a perceived client error
401UnauthorizedThe request has not been applied because it lacks valid authentication credentials for the target resource
403ForbiddenThe server understood the request but refuses to fulfill it
404Not FoundThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists
422Unprocessable ContentThe server understands the content type and the syntax of the request content is correct, but it was unable to process the contained instructions

RFC 9110 gives an example for 422: a request carrying XML that is well formed, or syntactically correct, but semantically erroneous. The 400 definition, by contrast, lists malformed request syntax among its examples. The same standard says a server that wants to hide the existence of a forbidden resource may respond with 404 instead of 403.

Where the 400 code is registered

The IANA HTTP Status Code Registry lists 400 as Bad Request and cites RFC 9110, Section 15.5.1 as its reference. The registry describes the 4xx class as client errors where the request contains bad syntax or cannot be fulfilled.

RFC 9110 was published in June 2022 as an Internet Standards Track document from the Internet Engineering Task Force, and it obsoletes earlier specifications including RFC 7231.

Have another question?