Exploring 400 Bad Request
Occasionally, you may run into a recurring issue with some of your websites: NGINX returns 400 Bad Request
error pages to random visitors, and this only stops happening when visitors clear their cache and cookies. The error is caused by an overly large header field sent by the client. Most of the time, this is when cookie data exceeds a certain size. In order to prevent further trouble, you can simply increase the value of the large_client_header_buffers
directive in order to allow a larger cookie data size:
large_client_header_buffers 4 16k;
In addition to adjusting the large_client_header_buffers
for resolving 400 Bad Request errors, it’s also worth examining directives such as proxy_buffers
, proxy_buffer_size
, and proxy_busy_buffers_size
. Modifying these settings can further mitigate error 400 by optimizing how NGINX handles incoming data.