Nginx connection reset

connectiongoogle analyticsnginx

When first visiting my site after not visiting it for a few minutes, the connection is "reset" 100% of the time.

I get this message when debug is turned on, along with a 400 bad request status message:

client prematurely closed connection while reading client request line

I've read that this could be caused by large_client_header_buffers setting. I have google analytics on my site. Using live http headers, I get this as the request:

“GET /__utm.gif?utmwv=5.3.7&utms=35&utmn=745612186&utmhn=domain.com&utmcs=UTF-8&utmsr=1920×1080&utmvp=1841×903&utmsc=24-bit&utmul=en-us&utmje=1&utmfl=11.4%20r402&utmdt=2006Scape%20Forums%20-%20General&utmhid=2004697163&utmr=0&utmp=%2Fservices%2Fforums%2Fboard.ws%3F3%2C4&utmac=UA-25674897-2&utmcc=__utma%3D68455186.1647889527.1351640625.1352446442.1352451659.100%3B%2B__utmz%3D68455186.1352097329.64.2.utmcsr%3Ddomain.com%7Cutmccn%3D(referral)%7Cutmcmd%3Dreferral%7Cutmcct%3D%2Fservices%2Fforums%2Fboard.ws%3B&utmu=q~ HTTP/1.1
`

my large_client_header_buffers in nginx is set to 4 8k, so I don't know if this is the problem. Immediate requests have the first "reset" request are all successful.

Best Answer

In most cases 400 status in access logs like this:

127.0.0.1 - - [09/Nov/2012:16:01:01 +0000] "-" 400 0 "-" "-"

and the message

... [info] ... client prematurely closed connection while reading client request line ...

in nginx error logs is a result of a browser opening extra connection to nginx and closing it without sending any request into it. It is often seen when client's browser is Chrome and there isn't many resources to load on the page requested.

By itself these messages are harmless and not a problem (and that's why the logging level is info). If you see some problem along with these messages - you may want to elaborate more on the problem you have. If you just see the messages - don't be scared, they are harmless.