1

I made the basic blog demo from a rails tutorial in a book from 2007. I realized it's dated so I deleted the blog I made and began to redo it from a tutorial here: http://guides.rubyonrails.org/getting_started.html#creating-the-blog-application

I started from scratch and now I'm stuck on 4.3 on that link's instructions because when I type in http://localhost:3000/ I keep getting the default screen for Rails instead of "Hello, Rails!" like the tut says I should.

The instructions on 4.3 are to type in

rm public/index.html

And then access the routes.rb file to uncomment the root to: section so that it says

root :to => "welcome#index"

I continued on with the migration and all that but I still keep getting the default screen.

Then I typed

rails server -d

to see if that does the trick but nope. It just says this only ending with the 2nd =>:

blog ❯ rails server -d
=> Booting WEBrick
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000

If I just type

rails server

I get an error in terminal that says the following:

blog ❯ rails server

=> Booting WEBrick

=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server

[2012-05-28 17:42:34] INFO  WEBrick 1.3.1

[2012-05-28 17:42:34] INFO  ruby 1.9.3 (2012-02-16) [x86_64-darwin11.3.0]

[2012-05-28 17:42:34] WARN  TCPServer Error: Address already in use - bind(2)
Exiting

/Users/Nick/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/utils.rb:85:in     `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /Users/Nick/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/utils.rb:85:in `new'

If anyone wants me to paste the rest of the error I'll go ahead and do that.

I'm not sure what to do from here to fix this.

Thanks for your help

1 Answer 1

8

TCPServer Error: Address already in use - bind(2)

One of two things is happening:

  1. You already have a WEBrick server running elsewhere on port 3000. Kill it before starting a new one.
  2. Some other process is listening on port 3000

The first time you did rails server -d, you started a backgrounded WEBrick service that is eating port 3000. Find the running process and kill it via:

ps aux | grep ruby
kill  [PID from above]

Then restart your WEBrick with just rails server. At this point, having already removed the public/index.html, your route should be active and working.

Sign up to request clarification or add additional context in comments.

7 Comments

What is a PID? Here is what gets outputted with the first command:
blog ❯ ps aux | grep ruby ⏎ Nick 76817 0.0 1.5 2526352 63420 ?? S 5:42PM 0:01.14 /Users/Nick/.rvm/rubies/ruby-1.9.3-p125/bin/ruby script/rails server -d Nick 77597 0.0 0.0 2434892 424 s000 R+ 6:20PM 0:00.00 grep ruby
@ninja08 Process Id -- usually the first number output from the ps aux, following the username. In your output, it is 76817. The second one is the process of you checking the process :)
@ninja08 So now the route works, but you have not generated a WelcomeController yet so it fails when you try to access it. Build the controller and index with rails generate controller welcome index
Try to use killall -9 ruby, hope it helps.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.