Ramji Makwana Ramji Makwana - 4 years ago 436
Node.js Question

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


  • I have tried number of "Error R10" Solutions, but it doesn't solve the problem for a simple Hello World like Nodejs app with server.js, package.json, index.html and node_module

  • Hereby adding server.js, package.json and error log

  • Currently trying this app on free heroku acount

  • Is it necessary to upload nodejs app on github to host it on heroku



server.js

var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');

var port = 3000;

var app = express();

// Set Static Folder
app.use(express.static(__dirname));
// Body Parser MW
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));


var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
app.use(express.static(__dirname + '/'));
} else {
app.use(express.static(__dirname + '/'));
}

app.get("/", function(req, res){
res.render("index.html");
});

app.listen(port, function(){
console.log("Server started ..!");
});


package.json

{
"name": "es1",
"version": "1.0.0",
"description": "eS",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.16.0",
"express": "^4.14.0"
}
}


Attaching heroku logs:



https://drive.google.com/open?id=0B4XtAe7mRM6UVllTQWh1dmplZk0

Answer Source

Change the value of port as follows:

var port = process.env.PORT || 3000;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download