scott.hodson.blog

November 11, 2007

WEBrick won’t start on Windows

Filed under: Rails, Ruby — scott @ 9:35 pm

If you get a strange error trying to start WEBrick on Windows like this…


[2007-11-11 20:23:42] INFO WEBrick 1.3.1
[2007-11-11 20:23:42] INFO ruby 1.8.6 (2007-03-13) [i386-mswin32]
[2007-11-11 20:23:42] 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 `new'
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 `each'
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.2.5/lib/webrick_server.rb:58:in `new'
... 7 levels...
from c:/bin/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/commands/server.rb:39
from c:/bin/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from c:/bin/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:3

This is most likely caused by some other already listening on the default port 3000. Perhaps you have another WEBrick server instance running. To see if you have another app running on that port you can run

netstat -a -b

To show the list of applications and what ports they are listening on. If you want to release the port just kill the application listening on that port, or you can run WEBrick on another port like 8080 like this:

ruby script/server -p8080

References:

Powered by WordPress