title: Node.js express app keep crashing on heroku
body: <p>I pushed a fairly simple node.js express app on heroku and can't make it works. It immeadiately crash. <code>heroku tail --logs</code> gives me :</p>
  
  <pre><code>2017-05-23T04:43:08.156660+00:00 app[api]: Scaled to web@1:Free worker@0:Free by user jp@yetie.fr
  2017-05-23T04:43:24.388293+00:00 heroku[web.1]: Starting process with command `: node server.js`
  2017-05-23T04:43:26.207926+00:00 heroku[web.1]: Process exited with status 0
  2017-05-23T04:43:26.220393+00:00 heroku[web.1]: State changed from starting to crashed
  2017-05-23T04:43:26.221461+00:00 heroku[web.1]: State changed from crashed to starting
  2017-05-23T04:43:43.343050+00:00 heroku[web.1]: Starting process with command `: node server.js`
  2017-05-23T04:43:44.751608+00:00 heroku[web.1]: Process exited with status 0
  2017-05-23T04:43:44.762870+00:00 heroku[web.1]: State changed from starting to crashed
  2017-05-23T04:43:46.400260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=yetie.herokuapp.com request_id=d7913d1e-64ab-497b-a59d-fda9454d6e69 fwd="81.56.46.53" dyno= connect= service= status=503 bytes= protocol=https
  2017-05-23T04:43:46.899099+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=yetie.herokuapp.com request_id=1fdc61fb-eebe-40a2-8b0a-a71b09f7ff10 fwd="81.56.46.53" dyno= connect= service= status=503 bytes= protocol=https
  </code></pre>
  
  <p>I have a Procfile that contains : </p>
  
  <pre><code>web : node server.js
  worker: node workers/match.js
  </code></pre>
  
  <p>worker, run as expected.
  server.js looks like this :</p>
  
  <pre><code>const express = require('express');
  const app = express();
  
  app.use(express.static(__dirname + '/testheroku'));
  
  app.listen(process.env.PORT || 8080, function(){
    console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
  });
  </code></pre>
  
  <p>In /testheroku dir there is a single "hello world" html file.</p>
  
  <p>When I run it locally with <code>heroku local web</code> it works, when I run it by connecting to heroku dyno with <code>heroku run bash</code> then <code>node server.js</code> and then doing a <code>wget http://localhost:xxxx</code> it properly get the "hello world" html file.</p>
  
  <p>But when I try to access the url heroku gives to me when I build the app, I get the above crash logs.</p>
  
  <p>Node and npm versions are the same locally and on heroku : </p>
  
  <pre><code>node --version =&gt; v6.10.3
  npm --version =&gt; 3.10.10
  </code></pre>
  
  <p>I may include the package.json file if requested, but it's fairly long (based on a more complex angular2 app) and it compiles properly both localy and on heroku. And as I manage to run <code>node server.js</code> by connecting to the dyno thru bash, I doubt the issue should be there.</p>
  
  <p>Most answers I found on stackoveflow or elswere suggest a port issue and to use the <code>app.listen(process.env.PORT || 8080)</code> trick, which I did. So what am I missing here ?</p>