I made a simple web app with Expressjs and Nodejs (using MEAN.js stack). I pulled my web app from git to my Openshift server using SSH access.
And after installing all modules, I configured my MongoDB URI, and then in order to launch my server I do this command on my project server :
NODE_ENV=production npm start
And I get this error :
Fatal error: listen EACCES
Warning: Used --force, continuing.
Running "nodemon:dev" (nodemon) task
[nodemon] v1.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Failed to open socket on port 5858, waiting 1000 ms before retrying
Application loaded using the "production" environment configuration
js-bson: Failed to load c++ bson extension, using pure JS version
Failed to open socket on port 5858, waiting 1000 ms before retrying
Failed to open socket on port 5858, waiting 1000 ms before retrying
Failed to open socket on port 5858, waiting 1000 ms before retrying
Failed to open socket on port 5858, waiting 1000 ms before retrying
Failed to load c++ bson extension, using pure JS version
Failed to open socket on port 5858, waiting 1000 ms before retrying
Failed to open socket on port 5858, waiting 1000 ms before retrying
MEAN.JS application started on port 8081
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1135:5)
at Function.app.listen (/var/lib/openshift/53be9cb55004467d130002a4/app-deployments/2014-07-10_10-01-30.769/MeanApp/node_modules/express/lib/application.js:532:24)
at Object.<anonymous> (/var/lib/openshift/53be9cb55004467d130002a4/app-deployments/2014-07-10_10-01-30.769/MeanApp/server.js:25:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
[nodemon] app crashed - waiting for file changes before starting...
In order to fix it I googled the error and looked in StackOverflow for solutions. It seemed to be a port problem so I tried to change port to 8080, 8081, 3000, but nothing fixed the problem.
Do you have any idea ?
You need to bind to the ip address and port 8080 of your gear, you can't bind to 0.0.0.0 (which is what it tries to do by default)