OpenShift node.js Error: listen EACCES

核能气质少年 提交于 2020-01-09 09:49:09

问题


I have been using OpenShift with node.js and socket.io. My code is:

server.listen(process.end.OPENSHIFT_NODEJS_PORT || 3000);

My code says that it returns port 8080. However, I get this error:

 DEBUG: Starting child process with 'node server.is'
 Info: socket.io started
 warn:error raised: Error: listen EACCES

How can I fix this? No other solution I can find works.


回答1:


You also need to specify to bind to your OPENSHIFT_NODEJS_IP in your listen, as it is trying to bind to 0.0.0.0 by default, which is not allowed.

Something like:

var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
server.listen( port, ipaddress, function() {
    console.log((new Date()) + ' Server is listening on port 8080');
});


来源:https://stackoverflow.com/questions/20974094/openshift-node-js-error-listen-eacces

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