Help - WEBrick won't start - "Bad file descriptor" error

I have been working for a few days on a new (Windows) system, and
suddenly WEBrick won’t start. Full error text is at bottom of message.

It began after I followed Brian H.'s (terrific!) instructions for
setting up Eclipse w/Rails in Windows
( The server started
fine from w/in Eclipse when I reached that part of the instructions, but
when I got to the end I found the server broken (hadn’t started the
server in the meantime, so I can’t say for sure when it happened).
WEBrick now doesn’t work from inside Eclipse or from the command line;
identical errors. I tried creating a new rails command-line project in
case the projects inside Eclipse were damaged; no difference.

I also tried rewinding, but even complete uninstall/reinstalls of ruby
and rails don’t fix the problem. These are completely basic projects –
no plug-ins, I haven’t even generated a scaffold or any
models/controllers yet.

Anyone able to shed any light?


///Here’s the trace:

Booting WEBrick…
=> Rails application started on
=> Ctrl-C to shutdown server; call with --help for options
[2006-02-26 17:09:10] INFO WEBrick 1.3.1
[2006-02-26 17:09:10] INFO ruby 1.8.4 (2005-12-24) [i386-mswin32]
[2006-02-26 17:09:10] WARN TCPServer Error: Bad file descriptor -
c:/bin/ruby/lib/ruby/1.8/webrick/utils.rb:73:in initialize': Bad file descriptor - bind(2) (Errno::EBADF) from c:/bin/ruby/lib/ruby/1.8/webrick/utils.rb:73:increate_listeners’
from c:/bin/ruby/lib/ruby/1.8/webrick/utils.rb:70:in
create_listeners' from c:/bin/ruby/lib/ruby/1.8/webrick/server.rb:75:inlisten’
from c:/bin/ruby/lib/ruby/1.8/webrick/server.rb:63:in
initialize' from c:/bin/ruby/lib/ruby/1.8/webrick/httpserver.rb:24:ininitialize’
in dispatch' from c:/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webr ick.rb:59 from c:/bin/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
t/dependencies.rb:214:in require' from c:/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 from c:/bin/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
t/dependencies.rb:214:in `require’
from script/server:3

/// Here’s the code around the point of failure (line 73):
/// c:/bin/ruby/lib/ruby/1.8/webrick/utils.rb

70 res.each{|ai|
71 begin
72 logger.debug(“{ai[3]}, #{port})”) if logger
73 sock =[3], port)
74 port = sock.addr[1] if port == 0
75 Utils::set_close_on_exec(sock)
76 sockets << sock
77 rescue => ex
78 logger.warn(“TCPServer Error: #{ex}”) if logger
79 last_error = ex
80 end

I had the same problem and posted about it here as well. I think it’s
somehow related to eclipse tying up a port. If you do a:

ruby script\server --port=8000

It should work fine. But you’ll have to navigate to
http://localhost:8000 instead.