If you've got a Node.js application running on OpenShift, chances are at some point you've seen a 503 error when deploying the application.
The OpenShift FAQ tells us to take a look at the log files in this situation.
Looking at the log files for my application, I was getting the following error:
> node app.js events.js:48 throw arguments; // Unhandled 'error' event ^ Error: listen EACCES at errnoException (net.js:670:11) at Array.0 (net.js:756:28) at EventEmitter._tickCallback (node.js:190:38) npm info email@example.com Failed to exec start script npm ERR! firstname.lastname@example.org start: `node app.js` npm ERR! `sh "-c" "node app.js"` failed with 1
This error (in OpenShift terms) seems to mean that the server is not listening on the correct port / address.
This can be fixed by ensuring that the Node.js server is configured to use the
process.env.OPENSHIFT_NODEJS_IP, for example:
app.listen(process.env.OPENSHIFT_NODEJS_PORT || 8080, process.env.OPENSHIFT_NODEJS_IP);
Specifically, I've found that when getting a 503, it means that you haven't specified an IP address. On OpenShift, Node.js apps seem to need to be supplied an IP address to bind to, a port is not sufficient.