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.
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.
server {
listen 443 ssl http2;
large_client_header_buffers 4 32k;
location /api/ {
proxy_pass https://backend_upstream;
proxy_set_header Host $host;
}
}
curl -i -sS -X POST -H 'Content-Type: application/json' -d '{"id":123}' https://api.example.com/v1/orders
Clear bloated cookies for the domain and raise `large_client_header_buffers 4 32k;` in your Nginx `http` or `server` block.
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.
Ensure WebSockets are enabled in Cloudflare Network settings and that `Upgrade` and `Connection` headers are forwarded properly.