Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

socket.io - OpenShift node.js Error: listen EACCES

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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');
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...