Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Getting Started with Rails Generate a Rails Application

Rodrigo Soares
Rodrigo Soares
2,460 Points

Problem starting server

Every time I try to start the server with the rails server entry I get this:

Rodrigos-MacBook-Air:~ RodrigoSoares$ cd treehouse/projects/treebook
Rodrigos-MacBook-Air:treebook RodrigoSoares$ rails server
=> Booting WEBrick
=> Rails 4.0.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-02-22 15:39:08] INFO  WEBrick 1.3.1
[2014-02-22 15:39:08] INFO  ruby 2.1.0 (2013-12-25) [x86_64-darwin11.0]
Exiting
/Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:3000 (Errno::EADDRINUSE)
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb:206:in `listen'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb:461:in `block in tcp_server_sockets'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb:232:in `each'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb:232:in `foreach'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/socket.rb:459:in `tcp_server_sockets'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/webrick/utils.rb:75:in `create_listeners'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/webrick/server.rb:132:in `listen'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/webrick/server.rb:113:in `initialize'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:45:in `initialize'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:11:in `new'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:11:in `run'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/server.rb:84:in `start'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap'
    from /Users/RodrigoSoares/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Can someone help me out? I'm a total rookie on developing...

3 Answers

James Barnett
James Barnett
39,199 Points

That error means there's another application using that port. Run this command to try to track down what it is:

sudo lsof -iTCP -sTCP:LISTEN -P | grep :3000
Nick Fuller
Nick Fuller
9,027 Points

Adding this command to my arsenal! Thanks James

Crisoforo Gaspar Hernández
Crisoforo Gaspar Hernández
18,302 Points

It seems like you already have a server online.

 Address already in use - bind(2) for 0.0.0.0:3000 (Errno::EADDRINUSE)

Have you double check that you close or terminate another server connection

Rodrigo Soares
Rodrigo Soares
2,460 Points

Yes both of you are correct. James, I just restarted my computer and it worked out. Thanks for helping.

James Barnett
James Barnett
39,199 Points

You probably started the server before, and it was still running. Learning how to see what servers are using which ports and learning how to kill those processes are an important skill to learn when starting out.