Can't reach nodejs on port 3000 from external on CentOS 7

江枫思渺然 提交于 2020-01-06 04:21:14

问题


I cant reach my node serve on port 3000. When I change port to 80 everything works well.

nodesjs:

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

app.get('/', function (req, res) {
    res.send('Hello World!');
});

app.listen(3000, '0.0.0.0', function () {
    console.log('server listening on port 3000!');
});

firewall:

firewall-cmd --zone=public --list-ports
3000/tcp

iptables:

Chain IN_public_allow (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 ctstate   NEW                                                                                                                                                             
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22 ctstate   NEW                                                                                                                                                              
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3000 ctstate NEW 

netstat:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1047/sshd
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      8308/node
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1730/master
tcp6       0      0 :::22                   :::*                    LISTEN      1047/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1730/master

for me everything looks ok?

来源:https://stackoverflow.com/questions/37723319/cant-reach-nodejs-on-port-3000-from-external-on-centos-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!