how to set node.js as a service on a private server?[can't access the node application]

谁说我不能喝 提交于 2019-12-25 07:36:02

问题


I have a problem when deploying my node.js on a private server. I just can't access it when i type the ip:5000 in the browser. This is what netstat shows:

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
126.0.54.248    0.0.0.0         255.255.255.248 U         0 0          0 eth1
0.0.0.0         126.0.54.249    0.0.0.0         UG        0 0          0 eth1

And this is my node.js code:

var express = require('express');
var app = express();
var http = require('http');

var port = 5000;
var server = http.createServer(app);

server.listen(port, function(err) {
    console.log(err, server.address()); // prints undefined { address: '0.0.0.0', family: 'IPv4', port: 5000 }  
});

I also added the ip address in my hosts file. What am I doing wrong that I can not access the webserver?(Yes I have the node server running)

来源:https://stackoverflow.com/questions/18184798/how-to-set-node-js-as-a-service-on-a-private-servercant-access-the-node-appli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!