Errno::EBADF 4

Posted by Ric Sun, 27 Aug 2006 14:18:00 GMT

Sometimes, when trying to start my rails server with the usual command:

ruby script/server
I get the following error:
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-08-27 15:10:09] INFO WEBrick 1.3.1
[2006-08-27 15:10:09] INFO ruby 1.8.4 (2006-04-14) [i386-mswin32]
[2006-08-27 15:10:09] WARN TCPServer Error: Bad file descriptor - bind(2)
c:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Bad file descriptor - bind(2) (Errno::EBADF)
 from c:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
 from c:/ruby/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
 from c:/ruby/lib/ruby/1.8/webrick/server.rb:75:in `listen'
 from c:/ruby/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
 from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
 from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:59:in `dispatch'
 from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
 from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
 from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
 from script/server:3

I realised that if I started the server on a different port, it worked (although I can’t see how the error relates to this) e.g.

ruby script/server -p8000

Sometimes even restarting the computer doesn’t solve the problem. Something must be running on port 3000 somtimes, but I can’t figure out what! At least using a different port for my server lets me continue working.

UPDATE: See my next post for a way to get round this problem.

Trackbacks

Use the following link to trackback from your own site:
http://www.ricroberts.com/trackbacks?article_id=errno-ebadf&day=27&month=08&year=2006

Comments

Leave a comment

  1. ian 5 months later:

    Thanks for the help – this solved my problem also. I just picked a different port and all was well again.

  2. Luke 6 months later:

    Picking a different port worked for me too. I wonder what is causing this…

    Firewall issue perhaps?

  3. Rich 6 months later:

    Glad it solved it for you. For me it was caused by my PDA being in its dock. (See the subsequent post).

  4. Luke 6 months later:

    LOL! I did have a WinCE based handheld in the cradle and ActiveSync running at the time. Nice catch!

Comments