簡體   English   中英

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://(server's IP):4000 結果

無法訪問此站點(服務器的 IP)拒絕連接。

好的,所以我不得不像這樣在防火牆中打開端口:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM