简体   繁体   English

如何在Linux服务器上设置节点项目?

[英]How to setup node project to the linux server?

node project run completely fine on localhost but not able to run on domain, Please help me to resolve this this. 节点项目可以在localhost上正常运行,但不能在域上运行,请帮助我解决此问题。

app.listen(3000,'APP_PRIVATE_IP_ADDRESS' function(err,rslt){
    if(err){
        console.log(err);
    }
    else{
    console.log("App Started on PORT 3000");
}
})

when i run the node server.js on terminal it print the message "App Started on PORT 3000" but when i run on the web it shows the error site can't be reached. 当我在终端上运行节点server.js时,它会显示消息“ App Started on PORT 3000”,但当我在Web上运行时,它表明无法访问错误站点。

Try using '0.0.0.0' symbolic IP, it means bind all IP's or any IP. 尝试使用“ 0.0.0.0”符号IP,这意味着绑定所有IP或任何IP。

app.listen(3000, '0.0.0.0', function(err, rslt){
    if(err){
        console.log(err);
    }
    else{
        console.log("App Started on PORT 3000");
    }
});

Hostname is optional, so this is equivalent: 主机名是可选的,因此等效:

app.listen(3000, function(err, rslt){
    if(err){
        console.log(err);
    }
    else{
        console.log("App Started on PORT 3000");
    }
});

In the case of that you want to specify the IP version, this two usage make difference. 在要指定IP版本的情况下,这两种用法会有所不同。 If you provide '0.0.0.0' value for hostname parameter, only IPv4 binding happens and only IPv4 request are accepted and listened. 如果为主机名参数提供“ 0.0.0.0”值,则仅发生IPv4绑定,并且仅接受和侦听IPv4请求。 If this parameter is not specified, both IPv6 and IPv4 bindings happen. 如果未指定此参数,则将同时发生IPv6和IPv4绑定。

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

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