Cannot connect to Localhost: 3000 for Rails, but 127.0.0.1∗000 works

I am learning Ruby on Rails with railstutorial.org and have encountered this strange problem.

I started the "rails" server and the following information showed:

=> Booting WEBrick
=> Rails 4.0.4 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-04-02 01:28:18] INFO  WEBrick 1.3.1
[2014-04-02 01:28:18] INFO  ruby 2.0.0 (2014-02-24) [x86_64-darwin12.5.0]
[2014-04-02 01:28:18] INFO  WEBrick::HTTPServer#start: pid=13004 port=3000

I am trying to connect to localhost: 3000 in different browsers, and all of them cannot connect to the server.

I also tried the rails -p 3001 server and connected to localhost: 3001, which also failed.

However, I tried 0.0.0.0ogi000, 127.0.0.1lla000, both of them worked and provided a default greeting for the rails.

Then I tried localhost: 80, which successfully told me "It Works", and I can really connect to another local project using PHP + Apache.

, , , - - .

:)

+4
2

. , ubuntu,

sudo nano /etc/hosts

, ok else .

127.0.0.1       localhost

localhost: 3000 Localhost: 3000

+4

localhost - 127.0.0.1

localhost:3000 , 127.0.0.1:3000 , , localhost ( hosts), Sabyasachi Ghosh

,

0

Source: https://habr.com/ru/post/1534593/


All Articles