What HTTP 400 means
A catch-all client error: invalid JSON, a missing required parameter, a malformed header or a bad query string. The problem is in the request, so retrying it unchanged will fail again. Good APIs explain what was wrong in the body, ideally in a structured format like RFC 9457 problem details.
How to fix a 400 error
- Validate the JSON body: a trailing comma or single quotes are enough to trigger 400.
-
Check
Content-Type: sending JSON asapplication/x-www-form-urlencodedoften causes 400. - Huge cookies or headers can also produce “400 Bad Request – Request Header Or Cookie Too Large” in nginx. Clear the site’s cookies.
Retrying
No. Fix the request first; sending it again unchanged will get the same response.
Example response
HTTP/1.1 400 Bad Request
Date: Wed, 21 Oct 2026 10:30:00 GMT
Content-Type: application/problem+json
How to return 400
res.status(400).json({ error: 'Bad Request' });
from fastapi import HTTPException
raise HTTPException(status_code=400, detail="Bad Request")
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
location /private/ {
return 400;
}
Related status codes
- 422 Unprocessable Content : The request is well-formed, but its contents fail validation.
- 415 Unsupported Media Type : The server doesn’t accept the request body’s format.
- 431 Request Header Fields Too Large : The request headers, often cookies, are too large for the server.
Other 4xx status codes
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 Content 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 Content · 423 Locked · 424 Failed Dependency · 425 Too Early · 426 Upgrade Required · 428 Precondition Required · 429 Too Many Requests · 431 Request Header Fields Too Large · 444 No Response · 451 Unavailable For Legal Reasons · 499 Client Closed Request
See the full list of HTTP status codes.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What does HTTP 400 Bad Request mean?
HTTP 400 Bad Request means the server can’t process the request because it is malformed. A catch-all client error: invalid JSON, a missing required parameter, a malformed header or a bad query string. The problem is in the request, so retrying it unchanged will fail again. Good APIs explain what was wrong in the body, ideally in a structured format like RFC 9457 problem details.
How do I fix HTTP 400?
Validate the JSON body: a trailing comma or single quotes are enough to trigger 400. Check Content-Type: sending JSON as application/x-www-form-urlencoded often causes 400. Huge cookies or headers can also produce “400 Bad Request – Request Header Or Cookie Too Large” in nginx. Clear the site’s cookies.