最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Connecting to localhost:8080 using Google Chrome - Stack Overflow

programmeradmin6浏览0评论

I'm currently developing a card game using node.js and gulp, and suddendly Chrome stopped to find localhost:8080. After some research, some people had the same problem and solved it by disabling "Built-in Asynchronous DNS" in chrome://flags, however, this flag seems not to exist anymore.

When a friend of mine launch the same code also with gulp and with the same version of Chrome, it works. Any idea ?

I'm currently developing a card game using node.js and gulp, and suddendly Chrome stopped to find localhost:8080. After some research, some people had the same problem and solved it by disabling "Built-in Asynchronous DNS" in chrome://flags, however, this flag seems not to exist anymore.

When a friend of mine launch the same code also with gulp and with the same version of Chrome, it works. Any idea ?

Share Improve this question asked Jun 11, 2015 at 18:57 KahsiusKahsius 8372 gold badges9 silver badges19 bronze badges 5
  • 2 try "127.0.0.1" IP instead. – Zero Commented Jun 11, 2015 at 19:01
  • 1 What does chrome say when you try to go to localhost:8080? Are you sure the server is running? Show us the code for your node server. Specifically the part where you call .listen(port);. – ChevCast Commented Jun 11, 2015 at 19:01
  • @Zero : Thanks for your answer, actually 127.0.0.1 works, What is the difference with localhost ? – Kahsius Commented Jun 11, 2015 at 19:20
  • I don't recall exact terms, but "localhost" is used as a reference to own IP and "127.0.0.1" the default IP for your own PC. Some programs simply do not accept localhost. It's odd it doesn't work on your PC and works on your friends one (which is why I still can't call my suggetion an "answer"). – Zero Commented Jun 11, 2015 at 19:53
  • You might check your hosts file (e.g. /etc/hosts on *nix or %SystemRoot%\system32\drivers\etc\hosts on Windows) to see what localhost is pointing to. – mscdex Commented Jun 11, 2015 at 20:55
Add a ment  | 

4 Answers 4

Reset to default 6

In the chrome url bar type "chrome://net-internals/#hsts" and delete the localhost domain, by typing "localhost" into the Delete Domain text box.

Type "localhost" into the Query Domain text box and if it says "Not found" than it was successful.

I was running into this issue as well. None of the other answers worked for me.

What did work for me was simply changing the port of my localhost to 3000.

Using Webpack:

// webpack.config.js 

module.exports = {
  ...
  devServer: {
    port: 3000,
  },
  ...
};

I am not very experienced in web developing and this might not be a very good answer. I am new to stackoverflow, so I cannot add any ments. That is why I post this as an answer to share my experiences.

One possible scenario is that you are already running an application that uses port 8080. As an example, if I use WAMP server to host a web page in port 8080 and Node.js to run a REST API in port 8080, one application might run on localhost:8080 and other on 127.0.0.1:8080 even though they are the same and the webpage will not be able to use the REST API because the hosts do not match. In fact, this happened to me while ago and I could not find a solution for it. So I had to serve the web page through Node.js. Hope this answer is helpful.

You should see the /etc/hosts file to find out the DNS pointing and secondly use 127.0.0.1 should point to your hostname or default server for the local host to work.

The DNS can't find anything running your localhost:8080, because either something else is running there or you simply didn't tell your localhost i.e. 127.0.0.1 to point towards your server.

发布评论

评论列表(0)

  1. 暂无评论