Heroku Node.js Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

After lots of googling I decided to npm install express and add

var express = require('express');
var app     = express();

app.set('port', (process.env.PORT || 5000));

//For avoidong Heroku $PORT error
app.get('/', function(request, response) {
    var result = 'App is running'
    response.send(result);
}).listen(app.get('port'), function() {
    console.log('App is running, server is listening on port ', app.get('port'));
});

This fixed the error, even though I don't like adding express just to avoid one error. If someone finds a better solution, please let me know.


If your app doesn't listen any port then you should use another type of app in you Procfile, I mean in Procfile you have:

web: node app.js

replace it with:

worker: node app.js

"web" type of application means that your app MUST listen some port


Another way would be changing the dynos from web (standard setting regardless of the settings in Procfile) to worker with these commands:

heroku ps:scale web=0
heroku ps:scale worker=1

Sometimes Heroku ignores settings in the Procfile.

Tags:

Heroku

Node.Js