app error: Socket is not connected (Errno::ENOTCONN)

Eric Wong normalperson at
Fri Apr 27 19:53:58 UTC 2012

Eric Wong <normalperson at> wrote:
> George <lists at> wrote:
> > Just fyi, my dev logs are now rife with these:
> > 
> > Will plug your patch in, but will have to figure out another option for
> > heroku deployment.
> Is this affecting your heroku deployment?  What OS/kernel version
> are you running?  From what Joel and Matt say, it could be more likely
> to trigger on *BSD-based systems.

Also, if you revert my previous patch, does this also prevent the error
from manifesting?

(I expect ignoring ENOTCONN _once_in_a_while_ will be required,
 but definitely not every request).

diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
index 14a6f9a..bb91e7f 100644
--- a/lib/unicorn/http_server.rb
+++ b/lib/unicorn/http_server.rb
@@ -537,7 +537,7 @@ class Unicorn::HttpServer
     @request.headers? or headers = nil
     http_response_write(client, status, headers, body)
-    client.shutdown # in case of fork() in Rack app
+    client.close_write # in case of fork() in Rack app
     client.close # flush and uncork socket immediately, no keepalive
   rescue => e
     handle_error(client, e)

More information about the mongrel-unicorn mailing list