← Back to all status codes
4xx Series
Terminal (Do not automatically retry)
400 Bad Request
The server cannot process the request because the client sent invalid syntax, malformed JSON, missing fields, or headers the endpoint cannot accept.
🌍
SEO Impact
Negative if encountered by crawlers. HTTP 400 can signal malformed internal links, invalid URL encoding, broken faceted navigation, or server rules rejecting Googlebot requests.
🔧
Common Causes
- 1Invalid JSON body or wrong Content-Type header
- 2Missing required query parameters or form fields
- 3Malformed URI strings, unencoded spaces, or invalid characters
- 4Request body exceeds validation rules before application logic runs
- 5API schema mismatch after a client or backend deploy
Code Examples and Debugging Commands
curl
curl -i -X POST https://api.example.com/users \
-H 'Content-Type: application/json' \
--data '{"email":"test@example.com"}'Node.js (Express)
app.post('/users', express.json(), (req, res) => {
if (!req.body.email) {
return res.status(400).json({ error: 'email is required' });
}
res.status(201).json({ ok: true });
});Next.js Route Handler
export async function POST(request: Request) {
const body = await request.json().catch(() => null);
if (!body?.email) {
return Response.json({ error: 'email is required' }, { status: 400 });
}
return Response.json({ ok: true });
}Nginx
client_max_body_size 10m;
large_client_header_buffers 4 16k;How to Fix HTTP 400 Bad Request
A 400 Bad Request usually means the server rejected the request before application logic could complete. Start by checking the URL, headers, content type, JSON body, and required parameters. If the endpoint works in a browser but fails in code, compare the exact request payload with a known-good curl call.
- Validate JSON. Look for trailing commas, unescaped quotes, invalid dates, or a body sent as text instead of JSON.
- Check headers. Confirm
Content-Type, auth headers, and custom API version headers match the endpoint docs. - Inspect query params. Missing IDs, malformed arrays, and unencoded spaces often trigger 400 responses.
- Compare server logs. Framework validators often record the exact field that failed even when the client only sees "Bad Request."