Unicorn and HAProxy, 500 Internal errors after checks

Eric Wong normalperson at yhbt.net
Thu Dec 2 12:39:59 EST 2010

Pierre <oct at fotopedia.com> wrote:
> On Wed, Dec 1, 2010 at 8:58 PM, Eric Wong <normalperson at yhbt.net> wrote:
> > I'm not sure how Unicorn is actually replying to anything, does HAProxy
> > write *anything* to the socket?
> It does. To reproduce the behavior, start a unicorn, start a sniffing
> tool (ngrep for example), connect to the unicorn and disconnect
> immediately:
> Connecting endpoint:
> [08:22][virtual] root at infrabox:~# telnet localhost 2002
> Trying
> Connected to infrabox.virtual.ftnz.net.
> Escape character is '^]'.
> ^]
> telnet> quit
> Connection closed.

Hi, you started writing an HTTP message ("quit" can be a valid HTTP
method name) and disconnected; don't do that.

> Further packet inspection reveals that the 500 Internal Server Error
> is sent after the telnet has sent a FIN packet which means it will
> just be discarded. I understand logging it could be a DoS vector, but
> you must admit that seing 500's from the server without any obvious
> reason can be frightening at first.

You can enable Ruby debugging (pass '-d' to unicorn) to see exactly
which exception you got.  Really, it shouldn't matter, you should be
sending real HTTP requests for health checks.

Eric Wong

More information about the mongrel-unicorn mailing list