HTTP status code 400 indicates that the server cannot understand the client’s request due to incorrect request syntax. This is a client error status code, typically occurring in the following situations:
- Syntax Error: The syntax of the client’s request is incorrect, making it unparseable by the server.
- Request Parameter Error: Parameters included in the client’s request do not meet the server’s requirements.
- Request Header Issues: The format of request header fields is incorrect or the content is unsupported.
- Body Content Error: The content format of the request body is incorrect or unparseable by the server.
When the server returns a 400 status code, it indicates that there is a problem with the request sent by the client, which needs to be corrected and resubmitted. The server may also provide error details to help developers diagnose the issue.
For example, if a client sends an HTTP request but the format of the request line or headers is incorrect, the server might return the following response:
HTTP/1.1 400 Bad Request
Content-Type: text/html
Content-Length: 160
<html>
<head><title>Bad Request</title></head>
<body>
<h1>Error: 400 Bad Request</h1>
<p>Your browser sent a request that this server could not understand.</p>
</body>
</html>
In this example, the status code 400 indicates that the server cannot understand the request, and the response body contains a simple HTML page describing the error information.
When client developers encounter a 400 error, they should check the request’s syntax, parameters, header fields, and body content to ensure they comply with HTTP standards and the server’s requirements.
Related 4xx error code
- 401 Unauthorized
- 402 Payment Required
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 406 Not Acceptable
- 407 Proxy Authentication Required
- 408 Request Timeout
- 409 Conflict
- 410 Gone
- 411 Length Required
- 412 Precondition Failed
- 413 Payload Too Large
- 414 URI Too Long
- 415 Unsupported Media Type
- 416 Range Not Satisfiable
- 417 Expectation Failed
- 418 I’m a teapot
- 421 Misdirected Request
- 422 Unprocessable Entity (WebDAV)
- 423 Locked (WebDAV)
- 424 Failed Dependency (WebDAV)
- 425 Too Early
- 426 Upgrade Required
- 428 Precondition Required
- 429 Too Many Requests
- 431 Request Header Fields Too Large
- 451 Unavailable For Legal Reasons
- 499 Client Closed Request