简体   繁体   English

AngularJS教程无法在Chrome Mac中打开

[英]AngularJS tutorial can't open in Chrome Mac

Started official tutorial of AngularJS. 开始AngularJS的官方教程 It works fine in firefox, but can't open example and run tests on Chrome. 它在Firefox中工作正常,但无法打开示例并在Chrome上运行测试。

Chrome Version 34.0.1847.116
node --version v0.10.26
Mac OS X Version 10.9.2

Tried wget some json resource, it works. 尝试wget一些json资源,它的工作原理。

wget http://localhost:8000/app/phones/phones.json 
--2014-04-20 01:14:37--  http://localhost:8000/app/phones/phones.json
Resolving localhost (localhost)... ::1, 127.0.0.1, fe80::1
Connecting to localhost (localhost)|::1|:8000... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6845 (6.7K) [application/json]
Saving to: 'phones.json'

100%[======================================>] 6,845       --.-K/s   in 0s      

2014-04-20 01:14:37 (466 MB/s) - 'phones.json' saved [6845/6845]

HTTP logs: HTTP日志:

Starting up http-server, serving ./ on port: 8000
Hit CTRL-C to stop the server
[Sat, 19 Apr 2014 22:14:37 GMT] "GET /app/phones/phones.json" "Wget/1.15 (darwin13.0.0)"
[Sat, 19 Apr 2014 22:16:06 GMT] "GET /app/phones/phones.json" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Firefox/24.0"

Same resource on Chrome: Chrome上的相同资源:

Oops! Google Chrome could not connect to localhost:8000

Empty in Chrome Console and in Network: 在Chrome控制台和网络中为空: 在此处输入图片说明

Found solution for my case. 找到适合我的情况的解决方案。

Firstly started looking for proxies. 首先开始寻找代理。 After sniffing around loopback interface with wireshark, found that localhost is linked to ::1. 在用wireshark绕回环回接口后,发现本地主机已链接到:: 1。 "::1" is 127.0.0.1 for IPv6. 对于IPv6,“ :: 1”是127.0.0.1。

Firefox is somehow resolves the problem, but Chrome not. Firefox以某种方式解决了问题,但Chrome无法解决。

Simply add the line below to hosts file. 只需将以下行添加到hosts文件。

127.0.0.1 localhost

It fixes problem. 它解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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