Reputation: 332
I'm developing an API on NodeJS using express and I'm getting this error while trying to deploy it to Heroku:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I am using the process.env.PORT variable, as I found here on SO, but it is still not working. Here's the index.js code:
var express = require('express');
var app = express();
var bodyParser = require("body-parser");
app.use(bodyParser.json());
var router = require("./router");
app.use('/viatges', router);
app.listen(3000 || process.env.PORT,function(){
console.log("up and running on port "+process.env.PORT);
});
Do you have any idea of what could be causing this issue?
On the heroku logs i see this line
2017-04-01T11:44:07.091181+00:00 app[web.1]: up and running on port 27583
so I assume the PORT enviornment variable is correctly set up...
Upvotes: 1
Views: 3104
Reputation: 332
Nevermind, i just fixed it. I changed the order of the operands in the OR, I assume javascript just went with the first as it was defined.
It now looks like this:
app.listen(process.env.PORT || 3000 ,function(){
console.log("up and running on port "+process.env.PORT);
});
Upvotes: 2