This happens if the client closes the connection to the web server, and the web server closes the connection to the FastCGI backend.

The problem is that ruby terminates (this is not an “exception”, so you cannot catch it); a good sysadmin will use runit (or similar), so it will be restarted, but as long as it is down, connections to the backend won’t get accepted, resulting in 500 Internal Server errors or similar.

To fix this bug, we need to change two things:

ruby-fcgi

My version is fcgi-0.8.8 from 2010… I changed the CHECK_STREAM_ERROR in fcgi-0.8.8/ext/fcgi/fcgi.c (whitespace fail – mixing tabs and spaces):