Forum: Ruby on Rails Help - WEBrick won't start - "Bad file descriptor" error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bd3f2aa23d93d13d1053828e417cb4dc?d=identicon&s=25 Christopher J. Mackie (Guest)
on 2006-02-26 23:30
(Received via mailing list)
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 Hogan's (terrific!) instructions for
setting up Eclipse w/Rails in Windows
(http://www.napcs.com/howto/railsonwindows.html). 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?

--CJ

/////////////////
///Here's the trace:

 Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> 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 -
bind(2)
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:in
`create_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:in `listen'
	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:in
`initialize'
	from
c:/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:61:
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:in
`require'
	from
c:/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_suppor
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:in
`require'
	from
c:/bin/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_suppor
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("TCPServer.new(#{ai[3]}, #{port})") if logger
73          sock = TCPServer.new(ai[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
455ac2a64d06dc8461f4d258d7f7e980?d=identicon&s=25 Michael Trier (Guest)
on 2006-02-27 02:54
(Received via mailing list)
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.

Michael
This topic is locked and can not be replied to.