node.js - NodeJS + Fedora 32 拒绝连接
问题描述
最简单的服务器(与 '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
推荐阅读
- laravel-8 - 为什么我从 Laravel 8 CsrfMiddleware 受保护的端点收到 419 响应?
- verilog - 主从JK触发器无输出
- php - 从 Laravel 8 的一个输入字段中选择多个类别
- powershell - 从 Windows 应用商店下载的倒数计时器
- linux - ss 摘要关闭数与关闭过滤器不匹配?
- python - 为什么我可以在 selenium 中找到这个文本框元素?
- azure-functions - .net 5 Azure Function 多部分文件上传问题
- laravel - Laravel Eloquent 在查询日期格式转换中遇到问题
- rpa - 操纵 Blueprism 集合
- python - 如何在 Dash (Plotly) 中使用本地网络摄像头在登录页面中显示直播?