Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails server is running, but cannot connect to localhost:3000

I am learning Ruby on Rails with railstutorial.org I had set everything up and working fine from Chapter 1. However, all of a sudden my next app has an issue.

I run "rails server"

=> Booting WEBrick
=> Rails 3.2.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-11-15 00:45:08] INFO  WEBrick 1.3.1
[2012-11-15 00:45:08] INFO  ruby 1.9.3 (2012-11-10) [x86_64-linux]
[2012-11-15 00:45:08] INFO  WEBrick::HTTPServer#start: pid=2752 port=3000

Seems to be working fine, just like with my previous app.

However, I try connecting to localhost:3000 , 0.0.0.0:3000 , 127.0.0.1:3000 on various browsers and they all cannot establish a connection to the server.

Some things to note:

-I was able to connect to localhost just a while ago--it just seems like it suddenly stopped working out of the blue.

-My first app was working perfectly fine, but now it doesn't work for my first app either.

-I don't have firewalls blocking the port, and my hosts file is not the problem.

-I am on Ubuntu 12.10

I almost always find solutions via search, but not this time.. so I need some help please. It's very frustrating as I feel like it's a simple problem that I spent way too long being stuck on.

Thank you.

like image 607
Alexander Sung Avatar asked Nov 15 '12 09:11

Alexander Sung


3 Answers

Try running it in some other port like say 3001 as:
rails server -p 3001
If its working than than try it again on 3000 as the command above.
I thing some other software is using your 3000 port that's why its not responding.
Or for some advanced things see here

like image 78
Sivan Avatar answered Oct 06 '22 23:10

Sivan


with rails 4.2.0, the server binds to localhost by default, instead of 0.0.0.0. When working with a rails in a virtual box, accessing the server from the host computer, the binding address needs to be 0.0.0.0

Start rails server with -b0.0.0.0 to make the rails server accessible from the host computer/browser.

http://guides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server https://github.com/samuelkadolph/unicorn-rails/issues/12#issuecomment-60875268

like image 22
andrewleung Avatar answered Oct 07 '22 00:10

andrewleung


Make sure you run rake db:create before launching rails s.

like image 42
Seyon Avatar answered Oct 07 '22 00:10

Seyon