简体   繁体   English

linux 上的 Nodejs 无法在服务器外部访问

[英]Nodejs on linux not accessible outside Server

tried everything... port 8008 seems to be open but no luck.尝试了一切......端口8008似乎是开放的,但没有运气。 netstat shows 8008 to be listening netstat 显示 8008 正在监听

I can do curl localhost:8008 but not from an external machine using the ip address of my server我可以使用我的服务器的 ip 地址从外部计算机执行 curl localhost:8008 但不能从外部计算机执行

and yes, i want to host my nodejs on port 8008 (not 8080 - im using 8080 for something else)是的,我想在端口 8008 上托管我的 nodejs(不是 8080 - 我使用 8080 做别的事情)

netstat output:网络统计 output:

tcp 0 0 0.0.0.0:8008 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8008 0.0.0.0:* 听

Have you tried changing your port您是否尝试过更改端口

var port = process.env.PORT || 8008;   //server.listen(3000, '0.0.0.0');
app.listen(port, 0.0.0.0, function() {
  console.log("Listening on " + port);
});

If you have .env insert value PORT=8008如果你有.env插入值PORT=8008

and run your server并运行你的服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM