5

I have a server that won't start correctly on openshift. This is my code:

var connect = require("connect");
var port = process.env.OPENSHIFT_NODEJS_PORT  || 8080;
var httpServer = connect.createServer(connect.static(__dirname + "/public")).listen(port);
console.log("Listening on " + port + "...");

I keep getting this error:

info: socket.io started warn: error raised: Error: listen EACCES DEBUG: Program node server.js exited with code 0 DEBUG: Starting child process with 'node server.js' Listening on 8080...

How can I solve this?

2 Answers 2

9

You need to bind the listening IP address to process.env.OPENSHIFT_NODEJS_IP. Here is the example from my working code (I'm using Express) on OpenShift.

var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
app.listen(port, ipaddress, function() {
    // Do your stuff
});
Sign up to request clarification or add additional context in comments.

Comments

3

We need to specify the binding to your OPENSHIFT_NODEJS_IP in your listen like:

var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1"; (do not forget quotes)
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.