DevToolsmith

HTTP 400 Bad Request

HTTP 400 Bad Request means the server can’t process the request because it is malformed. The request contains an error or can’t be fulfilled. Retrying unchanged won’t help.

Class
4xx Client error
Standard
RFC 9110
Cacheable by default
No
Safe to retry
No
Go constant
http.StatusBadRequest

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 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.

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

Node.js (Express)
res.status(400).json({ error: 'Bad Request' });
Python (FastAPI)
from fastapi import HTTPException

raise HTTPException(status_code=400, detail="Bad Request")
Go (net/http)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
nginx
location /private/ {
    return 400;
}

Related status codes

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.