Ruby-on-rails 无法访问 http://localhost:3000

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/551652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:58:40  来源:igfitidea点击:

Cannot access http://localhost:3000

ruby-on-railsnetworkinglocalhost

提问by Antony Scott

I am trying to learn Ruby on Rails, I have followed the instructions from this pageto get rails installed on my PC.

我正在尝试学习 Ruby on Rails,我已按照此页面中的说明在我的 PC 上安装了 Rails。

I am also trying to follow this webcastto try and learn the language and framework. Everything is working so far, apart from the fact that I cannot access

我也在尝试关注此网络广播以尝试学习语言和框架。到目前为止一切正常,除了我无法访问

http://localhost:3000
http://0.0.0.0:3000
http://127.0.0.1:3000, or
http://<actual IP address>:3000

locally. If I try the from another PC on my network then it works great. I have tried in Chrome, Firefox and IE7 but none work.

当地。如果我从我网络上的另一台 PC 上尝试,那么效果很好。我曾在 Chrome、Firefox 和 IE7 中尝试过,但没有成功。

Has anyone else had this problem?

有没有其他人有这个问题?

EDIT: Typical!! It's started working now. I have no idea why, I am typing the exact same address in to the address bar and it now works. But only if I use http://127.0.0.1:3000, localhost doesn't work. I do run IIS ASP.NET/ASP websites on this machine, and they work fine with localhost.

编辑:典型!!它现在开始工作了。我不知道为什么,我在地址栏中输入了完全相同的地址,现在它可以工作了。但只有当我使用时http://127.0.0.1:3000, localhost 才不起作用。我确实在这台机器上运行 IIS ASP.NET/ASP 网站,并且它们在本地主机上运行良好。

EDIT 2: If I trying pinging localhost it actually says

编辑 2:如果我尝试 ping localhost 它实际上说

Reply from ::1: time<1ms

0.0.0.0 yields...

0.0.0.0 收益率...

PING: transmit failed, error code 1214

only 127.0.0.1 seems to work. I did have IPv6 turned on, so I've disabled that and will try again tomorrow to see if a reboot helps.

只有 127.0.0.1 似乎有效。我确实打开了 IPv6,所以我已经禁用了它,明天再试一次,看看重新启动是否有帮助。

回答by Bob

I had this issue as well with Vagrant. The secret is to run

我和 Vagrant 也有这个问题。秘诀就是跑

bin/rails server -b 0.0.0.0

What 0.0.0.0 means is to listen to all interfaces, not just on localhost. The alternative is to SSH into the vagrant machine with a SOCKS proxy.

0.0.0.0 的意思是侦听所有接口,而不仅仅是在本地主机上。另一种方法是使用 SOCKS 代理通过 SSH 连接到 vagrant 机器。

ssh -C -D 8080 vagrant@localhost

Open up your Internet explorer proxy settings and set the SOCKS v5 proxy to port 8080.

打开 Internet Explorer 代理设置并将 SOCKS v5 代理设置为端口 8080。

回答by mhartl

In order to access http://localhost:3000you need to run the local Rails server in a terminal window:

为了访问,http://localhost:3000您需要在终端窗口中运行本地 Rails 服务器:

$ rails server

This is described in this section of the Rails Tutorial book.

在 Rails 教程书的这一节中有描述。

Note: I am the presenter of the screencasts in question.

注意:我是相关截屏视频的主持人。

回答by Yahs Hef

One way is to do the simple

一种方法是做简单的

    rails s

Another (more specifically) is

另一个(更具体地说)是

    rails start localhost 0.0.0.0

or

或者

    rails start 0.0.0.0

another way is

另一种方式是

    rails s 0.0.0.0

all of these works

所有这些作品

回答by Drew Noakes

Can you telnet to the port? Try:

你能telnet到端口吗?尝试:

telnet localhost 3000

That should tell you if the ports unavailable at the TCP level, or whether something's going on at the HTTP level.

这应该告诉您端口是否在 TCP 级别不可用,或者是否在 HTTP 级别发生了某些事情。

Ping might not work if ICMP is disabled, which could be completely unrelated to your issue.

如果 ICMP 被禁用,Ping 可能无法工作,这可能与您的问题完全无关。

Also, try looking in your hosts file for any redirections:

另外,尝试在您的主机文件中查找任何重定向:

c:\Windows\System32\drivers\etc\hosts

回答by Sanel Babic

I had an epic issue with my System Path (Environmental Variable) not being set properly.

我的系统路径(环境变量)设置不正确,遇到了一个史诗般的问题。

Simple copy paste job, unplugged the 1 week stalled Ruby installation.

简单的复制粘贴工作,拔掉了 1 周停滞的 Ruby 安装。

Control Panel > System > Advanced tab > Environment Variables > System variables > Path... Edit...

Control Panel > System > Advanced tab > Environment Variables > System variables > Path... Edit...

Make sure it contains these paths (among others)...

确保它包含这些路径(等等)...

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

回答by Edoardo

I had your same identical problem. You have simply to run

我有你同样的问题。你只需运行

$ rails server

from inside the folder of your application, not outside...so, if you have your application in

从您的应用程序文件夹内部,而不是外部...所以,如果您的应用程序在

C:\Sites\myapp\blog

C:\站点\我的应用程序\博客

and blog is the folder where live your app, the command has to be prompted from here. Launching it from myapp folder won't work.

和博客是您的应用程序所在的文件夹,必须从这里提示命令。从 myapp 文件夹启动它不起作用。

回答by bluebrother

Are you possibly using a proxy but haven't listed localhost as proxy exception?

您是否可能使用代理但未将 localhost 列为代理例外?

回答by Jason Baker

Have you tried disabling your firewall? They can cause pesky problems at times.

您是否尝试过禁用防火墙?它们有时会引起讨厌的问题。