400Bad Request
The server could not make sense of the request itself, so it did not try to act on it.
How you get a 400
A POST arrives with a body that is not valid JSON. The app cannot parse it, does nothing with it, and the app sends 400. The database is never touched.
Who sends itApp · Proxy · CDN
- Browser
- CDN
- Proxy
- App
- DB
Typically the app, when the body cannot be parsed. The proxy or CDN sends it when the request is broken at the HTTP level, such as oversized headers, and then the app never sees it.
In short
What a 400 Bad Request means
A 400 Bad Request means the server looked at what arrived and decided it was not a request it could work with: broken syntax, bad framing, a body that does not parse. Nothing was attempted, and sending the same bytes again will get the same answer. The useful question is which box rejected it. If the application did, the body is usually the problem: invalid JSON, a missing required parameter, the wrong content type. If the proxy or CDN did, the request broke rules of HTTP itself before the app ever saw it: headers or cookies that are too large, plain HTTP sent to an HTTPS port, illegal characters in the URL. The response body tells you which, because the proxy's error page looks nothing like your API's error format.
Common causes of a 400
1The body is not valid JSON, or does not match its Content-Type.
How to check: Validate the exact bytes you send, and check the Content-Type header.
jq . payload.json2Headers or cookies are larger than the proxy accepts.
How to check: The error page is nginx's own. Clear the site's cookies and try again.
400 Bad Request — Request Header Or Cookie Too Large3Plain HTTP was sent to a port that expects HTTPS.
How to check: nginx says so in the error page. Fix the scheme or the port in the URL.
The plain HTTP request was sent to HTTPS port4A required parameter is missing, or the URL contains characters that were not encoded.
How to check: Read the response body: most APIs name the field. Encode spaces and special characters in the URL.
Retry or not?
Retry only after fixing the request
Headers that matter
- Content-Type
- Request header. Must match the body. JSON sent as form data is a common 400.
- Content-Length
- Request header. A length that does not match the body breaks the request's framing.
- Cookie
- Request header. Grows over time and is the usual reason for “header too large”.
In the real world
RFC vs real deployments
RFC 9110 keeps 400 deliberately broad: anything the server sees as a client error. In practice it does double duty. Many APIs use it for every kind of bad input, including well-formed requests with invalid values, where 422 would be more specific. Neither choice is wrong as long as the API is consistent and the body says what to fix.
Seen in a real outage
Input that should have been rejected is a common root of large outages. At Cloudflare in 2024, a blank configuration reached a log pipeline instead of being refused, and hours later more than half the logs were still being lost.
Your turn
Which code is it?
Users who have been logged in for months start getting a plain white “400 Bad Request” page from nginx on every page. New users are fine. The app logs show no errors. What is the likely cause?
Often confused with
400 questions
- Who sends a 400 Bad Request?
- Typically the application, when it cannot parse the body. A proxy or CDN sends it when the request is malformed at the HTTP level, such as headers that are too large.
- How do I fix a 400 Bad Request as a visitor?
- Check the address for typos, then clear the cookies for that site. Oversized or damaged cookies are the most common cause on ordinary web pages.
- What is the difference between 400 and 422?
- A 400 says the request could not be understood at all. A 422 says it was understood, but its contents are not acceptable, such as a date that is in the past.
Sources: RFC 9110: 400 Bad Request (section 15.5.1) ↗ · nginx: large_client_header_buffers ↗ · Report a problem
Diagrams are our own simulations. All wording is original and paraphrases the linked sources.
Practise this in the DNS / HTTP track
Two-minute animated lessons, then boss fights from real outages. Free, no account needed.