Ruby 2.0 Bad file descriptor (Errno::EBADF)

Eric Wong normalperson at
Fri Aug 23 02:04:53 UTC 2013

Port Himmerland <port.himmerland at> wrote:
> hi. i've been trying to upgrade my stack to ruby 2.0 but keep getting this on ubuntu (not on my local os x):
> /hello/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:746:in `for_fd': Bad file descriptor (Errno::EBADF)
> this happens all the time for my legacy rails app, but i'm not able to reproduce on a tiny new rack app. i'm wondering if this could be related:

We've been prepared for close-on-exec by default since unicorn 4.1.0
over two years ago:

	commit 6ab27beeda3b0aaaa66f7cc4f734944a7aa84385
	Author: Eric Wong <normalperson at>
	Date:   Thu Aug 11 12:59:09 2011 -0700

	    future-proof against close-on-exec by default

Did you upgrade to Ruby 2.0.0 before upgrading to unicorn 4.1+?

More information about the mongrel-unicorn mailing list