HTTP 400 · 4XX RFC 9110 §15.5.1 Cacheable: No Retryable: No (fix client request)

HTTP 400 Bad Request: Root Causes & Production Fix Guide

HTTP 400 Bad Request means the server rejected the request due to malformed syntax, invalid JSON, an invalid Host header, corrupted cookies, or sending plain HTTP to an HTTPS port.

Top Root Causes of HTTP 400

Nginx Header Buffer & Proxy Scheme Fix for 400

server {
    listen 443 ssl http2;
    large_client_header_buffers 4 32k;
    location /api/ {
        proxy_pass https://backend_upstream;
        proxy_set_header Host $host;
    }
}

Verify with cURL

curl -i -sS -X POST -H 'Content-Type: application/json' -d '{"id":123}' https://api.example.com/v1/orders

Interactive Stack Diagnoser (HTTP 400)

Frequently Asked Questions

How do I fix 'Request Header Or Cookie Too Large' 400 in Nginx?

Clear bloated cookies for the domain and raise `large_client_header_buffers 4 32k;` in your Nginx `http` or `server` block.

When should I return 400 vs 422?

Use 400 for malformed syntax (invalid JSON, bad headers, missing required query params) and 422 when JSON parses cleanly but fails business or schema validation.

Why does Cloudflare return 400 Bad Request on WebSockets?

Ensure WebSockets are enabled in Cloudflare Network settings and that `Upgrade` and `Connection` headers are forwarded properly.

Related Status Guides & Header Tools