Rails server not running

rails

#1

Hey c9 community,
I am going through the Ruby on Rails tutorial by Michael Hartl. However, I am having trouble running the rails server. Example below… This has happened a few times by the way and the only way to fix it has been to start tutorial over, thus far.

/workspace/sample_app (static-pages) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 4.2.2 application starting in development on http://0.0.0.0:8080
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
[2015-12-30 04:17:51] INFO WEBrick 1.3.1
[2015-12-30 04:17:51] INFO ruby 2.2.1 (2015-02-26) [x86_64-linux]
Exiting
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:206:in bind': Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE) from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:206:inlisten’
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:461:in block in tcp_server_sockets' from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:232:ineach’
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:232:in foreach' from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:459:intcp_server_sockets’
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/utils.rb:70:in create_listeners' from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:133:inlisten’
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:114:in initialize' from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:45:ininitialize’
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:in new' from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:inrun’
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:286:in start' from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/commands/server.rb:80:instart’
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:80:in block in server' from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:intap’
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:75:in server' from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/commands.rb:17:in <top (required)>' from /home/ubuntu/workspace/sample_app/bin/rails:9:inrequire’
from /home/ubuntu/workspace/sample_app/bin/rails:9:in <top (required)>' from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/lib/spring/client/rails.rb:27:inload’
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in call' from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/lib/spring/client/command.rb:7:incall’
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/lib/spring/client.rb:26:in run' from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/bin/spring:48:in<top (required)>'
from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/lib/spring/binstub.rb:11:in load' from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.1.3/lib/spring/binstub.rb:11:in<top (required)>'
from /home/ubuntu/workspace/sample_app/bin/spring:13:in require' from /home/ubuntu/workspace/sample_app/bin/spring:13:in<top (required)>'
from bin/rails:3:in load' from bin/rails:3:in

nothing comes up when I try to run or view in the browser…
Why is this? And what can I do to fix it?


#2

Hi,

Thank you for writing in. The important thing in the above error log is:

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

This means that another instance of your rails server (that you started earlier probably) is still running. If you have multiple terminals open, see if you can find it and then kill it. If you don’t know what’s taking up port 8080, this FAQ article should help.

Have a great day and happy coding!

Regards,
​Mutahhir


#3

Mutahhir,
Thank you , it’s always comforting for us just starting off, that there are helpers like you out there in the rails community.
Thank You.