【问题标题】:express.js - server listening but localhost refused to connectexpress.js - 服务器监听但 localhost 拒绝连接
【发布时间】:2019-01-31 16:43:15
【问题描述】:

尝试开始设置基本服务器。这是我的代码:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
    res.send('this is fubar'); 
})

app.listen(3000, '0.0.0.0', () => console.log(`listening on port 3000`));

当我运行node server.js 时,listening on port 3000 被记录。

但是当我访问https://localhost/3000 时,我收到消息“无法访问此站点。Localhost 拒绝连接。”

我跑了netstat -ab | findstr :3000,但没有得到任何结果。我也试过端口 5000 和 80。我还能做什么?

使用 Windows 10。

【问题讨论】:

    标签: javascript node.js express server


    【解决方案1】:

    你提到了https://localhost/3000。一个问题是它应该是https://localhost:3000: 而不是/),另一个问题是你可能是想在本地主机上使用http。试试看:http://localhost:3000

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-25
      • 1970-01-01
      • 2014-06-08
      • 2021-12-16
      • 2021-07-03
      • 2016-06-21
      • 1970-01-01
      相关资源
      最近更新 更多