NodeJS + Fedora 32 拒绝连接

NodeJS + Fedora 32 refused to connect

最简单的服务器(与“0.0.0.0”相同的结果并删除此 属性)

const http = require('http');

function handleRequest(a,b) {
    console.log('!');
}

var server = http.createServer(handleRequest);

server.listen(4000, '0.0.0.0',  function(){
    console.log("Server is listening");
});

网络统计:

sudo netstat -tunlp
Active Internet connections (only servers)
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      669/sshd: /usr/sbin 
tcp        0      0 0.0.0.0:4000            0.0.0.0:*               LISTEN      5631/node           
tcp6       0      0 :::22                   :::*                    LISTEN      669/sshd: /usr/sbin 

访问http://(服务器IP)结果:4000

This site can’t be reached (server's IP) refused to connect.

好的,所以我不得不像这样在防火墙中打开端口:

firewall-cmd --zone=public --add-port=4000/tcp