499 error

Maxim Dounin mdounin at mdounin.ru
Thu Dec 1 10:13:44 UTC 2011


Hello!

On Thu, Dec 01, 2011 at 03:20:12AM -0500, lsdillard wrote:

> I have a configuration that uses nginx + unicorn + rails 3.1.  I have a
> load balancer in front of this, and the health checks are failing
> because nginx is sending a 499 response when I try to use a rails page
> for the health check.  I can see that the rails response was a 200 from
> the logs, but nginx turns this into a 499.  I understand that this means
> the client closed the connection, but its idle timeout is 60 seconds,
> and the rails log shows consistent sub-1 second response times.  There's
> a second, more frequent health check that just opens a TCP connection on
> port 80 and only validates that the connection was opened.  When I use a
> static page (either from rails public directory or from another
> directory), everything's fine.  I cannot figure out why nginx is sending
> this 499 response -- one page indicated it was because of not having the
> host in the request

The 499 response is never send, it's just as status for logs to 
show that client closed connection before nginx was able to reply 
anything.

You description suggests that load balancer uses half-closed tcp 
connection for health checks (i.e. shuts down it's part of a tcp 
connection after sending request).  This will result in 
499 for proxied requests, as nginx will detect connection close 
from client and will terminate request.  You may use

    proxy_ignore_client_abort on;
    # or fastcgi_ignore_client_abort, whatever you use

to prevent nginx from doing connection close checks. It will stop 
it from detecting connection close from clients as well though, so 
you may want to limit this setting to health checks only by adding 
separate location for health checks.

Alternatively, you may want to fix your load balancer to keep 
connection open, not half-closed.

Maxim Dounin



More information about the nginx mailing list