简体   繁体   中英

Cannot access http://localhost:3000

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

I am also trying to follow this webcast to 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.

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.

EDIT 2: If I trying pinging localhost it actually says

Reply from ::1: time<1ms

0.0.0.0 yields...

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.

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

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.

ssh -C -D 8080 vagrant@localhost

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

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

$ rails server

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

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

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

Can you telnet to the port? Try:

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.

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

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

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

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

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.

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM