简体   繁体   English

为什么我在 Node.js 上的 localhost 应用程序需要这么长时间/拒绝连接?

[英]Why does my localhost application on Node.js take so long/refuse to connect?

Why does my localhost:3000 application take so long to load?为什么我的 localhost:3000 应用程序需要很长时间才能加载? I have tried quite a lot of ways to solve this, such as:我已经尝试了很多方法来解决这个问题,例如:

  1. Disable IPv6禁用 IPv6
  2. Add localhost into the hosts file将 localhost 添加到hosts文件中
  3. Update npm and node.js to the latest version将 npm 和 node.js 更新到最新版本

The localhost doesn't load, and eventually, just stops loading and refuses to connect.本地主机不加载,最终只是停止加载并拒绝连接。 I don't know why this is happening.我不知道为什么会这样。 I am using Microsoft Edge and Windows 10.我正在使用 Microsoft Edge 和 Windows 10。

Here is my code:这是我的代码:

//jshint esversion:6
const express = require("express");
const app = express();

app.get("/", function(request, response) {
   response.send("Hello World");
});

app.listen(3000, function()
{
   console.log("Server is listening on port 3000.");
});

Any Help would be appreciated.任何帮助,将不胜感激。 Thanks.谢谢。

Edit: It used to load at least a little bit but never fully loaded, now it just refuses to connect.编辑:它曾经至少加载一点但从未完全加载,现在它只是拒绝连接。 :( :(

The command line exited the node application, but from my side, it said it was still running.命令行退出了节点应用程序,但在我这边,它说它仍在运行。 It must have just been a bug.它一定只是一个错误。 I restarted my pc and it worked.我重新启动了我的电脑,它工作了。

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

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