【问题标题】:I get "Error: connect ECONNREFUSED ip:4000" when I try to connect to the server built in nodejs当我尝试连接到 nodejs 中内置的服务器时,我得到“错误:连接 ECONNREFUSED ip:4000”
【发布时间】:2022-08-18 05:10:02
【问题描述】:

我有运行 nodejs 10 的 centos 6, 我有这个脚手架代码来测试我的应用程序服务器,但仍然给出错误:连接 ECONNREFUSED ip:4000

const express = require(\'express\')
const app = express()
const port = 3432
const https = require(\'https\');
app.get(\'/\', (req, res) => {
  res.send(\'Hello World!\')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

当我尝试将网址放入浏览器时,它显示无法访问此站点。 我喜欢服务器没有运行,但它正在运行。

  • 好吧,您的服务器正在侦听端口 3432,因此您将无法在端口 4000 上联系它
  • 是的,抱歉,我写的时候是端口错误。端口是一样的。错误可能是防火墙

标签: node.js express centos firewall


【解决方案1】:

错误是服务器管理员没有为我启用端口

【讨论】:

  • 他说他已经开放了港口
猜你喜欢
  • 2016-01-22
  • 2014-04-30
  • 2020-09-27
  • 2019-11-22
  • 1970-01-01
  • 2021-10-02
  • 2015-05-10
  • 1970-01-01
  • 2020-07-11
相关资源
最近更新 更多