端口打开但连接被拒绝...centos 8 / nginx / react / nodejs

问题描述

我在 pm2 上运行 nodejs 并在端口 5000 上侦听。如果我在服务器上运行 netstat -na |grep 5000 我得到

tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN

但是当我的 React 应用调用 http://localhost:5000/patients 时,我得到了

::ERR_CONNECTION_REFUSED

这是服务器的代码:

const app = express();
const port = process.env.PORT || 5000;

app.use('/patients',require("./routes/patientRoute"));


app.listen(port,"0.0.0.0",() => {
    console.log(`server is running on port: ${port}`);
})

并且从 React 生产构建中,我使用 axios 运行 GET 以 http://localhost:5000/patients 发生错误时

我也在firewalld上打开了端口

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)