title: heroku deployment of nodejs app - An error occurred in the application and your page could not be served. Please try again in a few moments
body: <p>I manually deployed an app on heroic (never done it before and just connected it to my github repository). It says deployed successfully but Im getting the error:</p>
  
  <pre><code>An error occurred in the application and your page could not be served. Please   
  try again in a few moments.
  If you are the application owner, check your logs for details.
  </code></pre>
  
  <p>My logs are:</p>
  
  <pre><code>2016-10-17T02:39:38.026918+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
  2016-10-17T02:39:38.026919+00:00 app[web.1]:     at Module.require (module.js:367:17)
  2016-10-17T02:39:38.026919+00:00 app[web.1]:     at require (internal/module.js:20:19)
  2016-10-17T02:39:38.026920+00:00 app[web.1]:     at Object.&lt;anonymous&gt; (/app/server/db/index.js:2:10)
  2016-10-17T02:39:38.026921+00:00 app[web.1]:     at Module._compile (module.js:413:34)
  2016-10-17T02:39:38.026921+00:00 app[web.1]:     at loader (/app/node_modules/babel-register/lib/node.js:144:5)
  2016-10-17T02:39:38.026922+00:00 app[web.1]:     at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-register/lib/node.js:154:7)
  2016-10-17T02:39:38.026923+00:00 app[web.1]:     at Module.load (module.js:357:32)
  2016-10-17T02:39:38.116826+00:00 heroku[web.1]: State changed from starting to crashed
  2016-10-17T02:39:38.917261+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pokemartapp.herokuapp.com request_id=90de2bee-e747-4901-8554-90aa3d57c1f1 fwd="68.105.253.103" dyno= connect= service= status=503 bytes=
  2016-10-17T02:43:14.022540+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pokemartapp.herokuapp.com request_id=589b8bf6-e786-43d6-b6e8-d9b09dca7586 fwd="68.105.253.103" dyno= connect= service= status=503 bytes=
  </code></pre>
  
  <p>My server:</p>
  
  <pre><code>var chalk = require('chalk');
  var db = require('./db');
  var server = require('http').createServer();
  
  var createApplication = function () {
      var app = require('./app')(db);
      server.on('request', app); // Attach the Express application.
      require('./io')(server);   // Attach socket.io.
  };
  
  var startServer = function () {
      var PORT = process.env.PORT || 1337;
  
      server.listen(PORT, function () {
          console.log(chalk.blue('Server started on port', chalk.magenta(PORT)));
      });
  };
  
  db.sync().then(createApplication).then(startServer).catch(function (err) {
     console.error(chalk.red(err.stack));
  });
  </code></pre>
  
  <p>My procfile:</p>
  
  <pre><code>web: node server/start.js
  </code></pre>
  
  <p>server/env/index.js: </p>
  
  <pre><code>var path = require('path'); var devConfigPath = path.join(__dirname, './development.js'); 
  var productionConfigPath = path.join(__dirname, './production.js'); 
  var testConfigPath = path.join(__dirname, './testing.js');     
  if (process.env.NODE_ENV === 'production') { module.exports =   
  require(productionConfigPath); } 
  else if (process.env.NODE_ENV === 'testing') { module.exports = require(testConfigPath);    } 
  else { module.exports = require(devConfigPath); } 
  </code></pre>
  
  <p>What does that mean? I have researched posts with the same problem and the proposed answers but nothing really helps..</p>