Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: listen EACCES on Openshift app

I have the following code

var express  = require('express')
    , app    = express()
    , server = require('http').createServer(app)
    , io     = require('socket.io').listen(server)
    , connect = require('connect')
    , pg     = require('pg')
    , Client = pg.Client;

// Setup express middleware
app.use(express.static('public'));
app.use(connect.logger());

// Start the server
var port = process.env.OPENSHIFT_INTERNAL_PORT || 8080
    , ip = process.env.OPENSHIFT_INTERNAL_IP || "127.0.0.1";
server.listen(port, ip);

But when the app start automaticaly or I start it manually with node I always receive the error: "warn: error raised: Error: listen EACCES"

The contents of package.json:

{
    "name"        : "test-app",
    "version"     : "0.0.1-1-alpha",
    "description" : "test-app",
    "dependencies": {
        "express"   : "3.1.x",
        "connect"   : "*",
        "socket.io" : "0.9.x",
        "i18next"   : "1.6.x",
        "bower"     : "1.1.1",
        "pg"        : "*"
    },
    "engines": {
        "node" : ">=0.10",
        "npm"  : "1.3.x"
    },
    "scripts": {
        "start" : "node app"
    }
}

What can I do to solve the problem? The sample server.js from openshift does not have this problem but it uses express 2.x.

like image 920
Victor Dodon Avatar asked Aug 11 '13 11:08

Victor Dodon


1 Answers

Looks like you're using old environment variables. Try:

// Start the server.
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080  
, ip = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
like image 183
Nam Duong Avatar answered Sep 28 '22 14:09

Nam Duong