Rails server is running, but cannot connect/ping/telnet to localhost

醉酒当歌 提交于 2019-12-11 13:50:15

问题


I'm working on ubuntu 15.04 (it's not a VM). I installed rails, ruby and bundler. Everything seems to work fine when I launch the server, as I get this:

sudo rails s -p 8080
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
=> Booting WEBrick
=> Rails 4.2.5.2 application starting in development on http://localhost:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-03-31 22:38:50] INFO  WEBrick 1.3.1
[2016-03-31 22:38:50] INFO  ruby 2.1.2 (2014-05-08) [x86_64-linux-gnu]
[2016-03-31 22:38:50] INFO  WEBrick::HTTPServer#start: pid=10415 port=8080

When I try to access to my localhost in my web browser I get "connection failed". So I tried to ping my localhost and I got:

$ ping localhost:8080
ping: unknown host localhost:8080

I also tried with telnet:

$ telnet localhost 8080
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

And when looking at the hostname mapping, I get this :

$ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   alex-VPCFXXXXX

After seeing that, everything seems to be normal... So I really don't get why it's not working and why I can't ping/telnet my localhost on this port (I tried with 3000 or 3001 just to be sure...)

Hope you can help me on this one :)

来源:https://stackoverflow.com/questions/36343740/rails-server-is-running-but-cannot-connect-ping-telnet-to-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!