Rails 服务器正在运行但未在浏览器中加载 [英] Rails server running but not loading in browser

查看:41
本文介绍了Rails 服务器正在运行但未在浏览器中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 vagrant VM 运行 rails,当我使用

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.

但是当我尝试使用 http://localhost:3000 访问它时,它没有加载.我开始了几周前,它运行良好,但后来我尝试卸载并重新安装(使用相同的资源和配置),因为我遇到了一些问题,从那时起它就不起作用了.我尝试在不同的端口上运行它:

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

仍然没有回应.我还尝试制作更多新应用程序并运行它们,以防万一我搞砸了一些默认配置但仍然无法正常工作.我现在正在使用 cloud9 IDE,但我在某处读到,在寻求职业生涯时不鼓励使用 IDE.不知道什么是真的,该怎么做.

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.

推荐答案

您的 Vagrantfile 中是否包含以下行?
config.vm.network :forwarded_port, guest: 3000, host: 3000 # rails

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

您可能已经启动了 VM 上的端口,但您的主机无法访问该端口.

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

(或者,为了证明这一点,您可以在 VM 中使用 lynx 来查看是否可以连接到您的站点)

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

[假设您在自己的机器上运行 Vagrant:对 Cloud9 位进入的位置有点困惑,除非您现在在 cloud9 中并想迁移到您自己的机器上运行 Vagrant 的机器...)]

[ 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...)]

这篇关于Rails 服务器正在运行但未在浏览器中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆