Rails server running but not loading in browser

2019-09-02 03:21发布

问题:

I I am running rails using vagrant VM and when i launch server with

`rails s`

It works fine and shows me that i am running server fine:

=> Booting WEBrick

=> Rails 4.2.3 application starting in development on http://localhost:3000

=> Run `rails server -h` for more startup options

=> Ctrl-C to shutdown server

[2015-08-22 17:46:42] INFO  WEBrick 1.3.1

[2015-08-22 17:46:42] INFO  ruby 2.2.1 (2015-02-26) [i686-linux]

[2015-08-22 17:46:42] INFO  WEBrick::HTTPServer#start: pid=3660 port=3000

♥[2015-08-22 17:48:09] INFO  going to shutdown ...


[2015-08-22 17:48:09] INFO  WEBrick::HTTPServer#start done.

BUt when i try to access it using http://localhost:3000 it doesn't load.I started a few weeks ago and it was working fine but then i tried to uninstall and reinstall(using same resources and configurations)because i had some problems and since then it's not working.I have tried running it on different port with:

rails s -p 3001

still no respond.And i also tried making more new apps and running them just incase i am messing up some default configurations and still not working.I am now using cloud9 IDE but i read somewhere that when seeking professional career IDE's are discouraged.Don't know what's true and what to do.

回答1:

Does your Vagrantfile have the following line in it?
config.vm.network :forwarded_port, guest: 3000, host: 3000 # rails

You may have started the port on your VM but given your host computer no way of getting to that port.

(Alternatively, to prove this you could use lynx in the VM to see if you could connect to your site)

[Edit: Assuming you're running Vagrant on your own machine: slightly confused where the Cloud9 bit is coming in, unless you're in cloud9 now and want to migrate off, to your own machine running Vagrant...)]