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?
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
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With