title: Heroku node js deployment issue: Web process failed to bind to $PORT within 60 seconds of launch
body: <p>I am trying to test a sample node js app by deploying it on Heroku. I am using mlab as my db cloud hosting. </p>
  
  <p>But I am unfortunately getting some errors. Here is the error log from Heorku: </p>
  
  <pre><code>2018-07-21T16:43:00.394188+00:00 heroku[web.1]: State changed from crashed to starting
  2018-07-21T16:43:03.124528+00:00 heroku[web.1]: Starting process with command `npm start`
  2018-07-21T16:43:06.239097+00:00 app[web.1]: 
  2018-07-21T16:43:06.239139+00:00 app[web.1]: &gt; quizgiri@1.0.0 start /app
  2018-07-21T16:43:06.239141+00:00 app[web.1]: &gt; node app.js
  2018-07-21T16:43:06.239142+00:00 app[web.1]: 
  2018-07-21T16:43:08.063152+00:00 app[web.1]: listening on port 3000 ...... 
  2018-07-21T16:44:03.476862+00:00 heroku[web.1]: Error R10 (Boot timeout) -&gt; Web process failed to bind to $PORT within 60 seconds of launch
  2018-07-21T16:44:03.476977+00:00 heroku[web.1]: Stopping process with SIGKILL
  2018-07-21T16:44:03.631909+00:00 heroku[web.1]: Process exited with status 137
  2018-07-21T16:44:03.646925+00:00 heroku[web.1]: State changed from starting to crashed
  2018-07-21T16:44:06.757320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/tasks" host=quizgiri.herokuapp.com request_id=9379fd55-584e-4693-8d51-75e06c1cce91 fwd="103.25.120.134" dyno= connect= service= status=503 bytes= protocol=https
  2018-07-21T16:44:12.243533+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quizgiri.herokuapp.com request_id=6654c0c4-5c8b-4e52-9539-27d52a3b0c6f fwd="103.25.120.134" dyno= connect= service= status=503 bytes= protocol=https
  2018-07-21T16:49:04.284636+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/tasks" host=quizgiri.herokuapp.com request_id=a1ed02bb-2fd7-491b-bbaf-81675c15a3c4 fwd="103.25.120.134" dyno= connect= service= status=503 bytes= protocol=https
  2018-07-21T16:49:05.395033+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quizgiri.herokuapp.com request_id=168d3a5c-8eb7-45fe-b16e-c1e3c4ef36a4 fwd="103.25.120.134" dyno= connect= service= status=503 bytes= protocol=https
  </code></pre>
  
  <p>my node js app has only two files.</p>
  
  <p>app.js:</p>
  
  <pre><code>const express = require("express");
  var router = express.Router();
  const app = express();
  var mongojs = require('mongojs');
  
  const port = process.env.port || 3000;
  
  var db = mongojs("my mlab connection string", ['testcollection']);
  
  //Get All Tasks
  app.get('/tasks', function(req, res, next){
      console.log(db);
      db.testcollection.find(function(err, tasks){
          if(err){
              res.send(err);
          }
          res.json(tasks);
      });
  });
  
  app.listen(port, () =&gt; {
      console.log(`listening on port ${port} ...... `);
  });
  </code></pre>
  
  <p>package.json : </p>
  
  <pre><code>{
    "name": "quizgiri",
    "version": "1.0.0",
    "description": "node server for quizgiri app",
    "main": "app.js",
    "scripts": {
      "start": "node app.js",
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
    },
    "author": "Anurag Bhattacharjee",
    "license": "ISC",
    "dependencies": {
      "express": "^4.16.3",
      "mongodb": "^3.1.0",
      "mongojs": "^2.6.0"
    }
  }
  </code></pre>