client closed prematurely connection while sending

2019-03-09 09:20发布

问题:

I have error in nginx error.log:

2010/12/05 17:11:49 [info] 7736#0: *1108 client closed prematurely connection while sending to client, 
client: 188.72.80.201, server:***.biz, request: "GET /forum/ HTTP/1.1", 
upstream:"http://***:3000/forum/", host: "***.biz"

I have 500 response code on site everytime. How can I fix this?

Thank you.

回答1:

Setting proxy_ignore_client_abort on; might help you.



回答2:

I tackled this problem myself for long hours today and found a solution:
Please note that this fix only affects you when using load balancer(s)

Check your load balancer idle timeout. I had ELB idle timeout set to 60 seconds (default) and as the request was hanging, it closed the connection after given time. But as the ELB is before nginx, nginx is logging that the "client" (in this case ELB), is closing the connection.

So if you are using ELB, go to:
EC2 -> Load Balancers -> Select the correct one -> scroll down in description and change Idle Timeout if you are using other load balancers, check their configuration and timeouts.

Also keep in mind that you still might be needing to change the proxy timeouts etc.



回答3:

I found that if you turn off the proxy buffer helps

http {
   proxy_buffering off;
...
}

Probably the buffers are too small or less. After changing the buffer sizes it works nice

proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 2048 8k;


回答4:

I had the same problem and researched on it. In my case this only happens with Webkit (Chrome) browsers. They open connections optimistically more connections than they require if you only load a single resource. In such a case, the excess connection is closed ungracefully or at least without sending any HTTP verb over it. This leads to the mentioned error in nginx.

Regarding #1 answer: Non of the proposed solutions help which is logical as this has nothing to do with proxying.

Regarding #2 answer: proxy_ignore_client_abort on; Does not help in my test.

Unfortunately, I've found no other solution than using

error_log off;



回答5:

I had same problem, found that nginx closes the connection because of send_timeout setting. I increased and it is fixed.

http
{
send_timeout 20;
...
}


回答6:

fastcgi_ignore_client_abort on will definitely solve the issue.



回答7:

I've started to see this message when changed error_log from warn to debug. Reverting solved the problem.



标签: nginx