Rails Server – Address Already in Use

Well, looks like the first thing I’ve managed to break today is WEBrick – a web server for ruby on rails. The general idea behind the error message appears to be that the address it’s trying to start is already in use:

[2011-12-02 19:01:34] INFO  WEBrick 1.3.1
[2011-12-02 19:01:34] INFO  ruby 1.8.7 (2010-08-16) [i686-linux]
[2011-12-02 19:01:39] WARN  TCPServer Error: Address already in use – bind(2)
/usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize’: Address already in use – bind(2) (Errno::EADDRINUSE)
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new’
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners’
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each’
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners’
from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen’
from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize’
from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize’
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/handler/webrick.rb:10:in `new’
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/handler/webrick.rb:10:in `run’
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/server.rb:265:in `start’
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in `start’
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands.rb:54
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap’
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands.rb:49
from script/rails:6:in `require’
from script/rails:6


Sure enough, it turns out that one of my previous WEBrick processes had not closed properly. I was able to view the existing processes using the following:
chris@chris-VirtualBox:~/site$ pgrep ruby


In order to close them simply kill the process:
chris@chris-VirtualBox:~/site$ kill 1601


Ensure that the process is gone:
chris@chris-VirtualBox:~/site$ pgrep ruby


And finally, start WEBrick again.
chris@chris-VirtualBox:~/site$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-02 19:13:21] INFO  WEBrick 1.3.1
[2011-12-02 19:13:21] INFO  ruby 1.8.7 (2010-08-16) [i686-linux]
[2011-12-02 19:13:26] INFO  WEBrick::HTTPServer#start: pid=1814 port=3000


Good luck!






One response to “Rails Server – Address Already in Use”

  1. Jansen Simanullang Avatar
    Jansen Simanullang

    If for some unknown reason the ‘kill’ command doesn’t work then you can try to run rails server in another port. Use the command: ‘rail server –port=3021’.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: