Saturday, 1 April 2017

Node app fails to bind to heroku port

I'm having trouble deploying my node/express app through Heroku. It runs fine locally, but when fails on Heroku. Here are the logs I'm getting:

2017-04-02T00:38:44.584532+00:00 heroku[web.1]: Starting process with command `npm start`
2017-04-02T00:38:47.292047+00:00 app[web.1]: 
2017-04-02T00:38:47.292065+00:00 app[web.1]: > roommate-matcher@1.0.0 start /app
2017-04-02T00:38:47.292066+00:00 app[web.1]: > node server.js
2017-04-02T00:38:47.292067+00:00 app[web.1]: 
2017-04-02T00:38:47.898461+00:00 app[web.1]: Example app listening at http://:::3000
2017-04-02T00:38:48.496009+00:00 app[web.1]: Hash: b8f55b865340dbca69b8
2017-04-02T00:38:48.496024+00:00 app[web.1]: Version: webpack 2.3.2
2017-04-02T00:38:48.496025+00:00 app[web.1]: Time: 589ms
2017-04-02T00:38:48.496026+00:00 app[web.1]:     Asset     Size  Chunks             Chunk Names
2017-04-02T00:38:48.496027+00:00 app[web.1]: bundle.js  2.81 kB       0  [emitted]  main
2017-04-02T00:38:48.496028+00:00 app[web.1]:     [0] ./src/main.js 43 bytes {0} [built]
2017-04-02T00:38:48.496029+00:00 app[web.1]:     [1] multi ./main.js 28 bytes {0} [built]
2017-04-02T00:38:48.496082+00:00 app[web.1]: webpack: Compiled successfully.
2017-04-02T00:38:48.496027+00:00 app[web.1]: chunk    {0} bundle.js (main) 71 bytes [entry] [rendered]
2017-04-02T00:39:02.372057+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=roommate-matcher.herokuapp.com request_id=03ea4b67-6c85-424d-946a-28386db2c58a fwd="67.164.74.61" dyno= connect= service= status=503 bytes= protocol=https
2017-04-02T00:39:45.102538+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-04-02T00:39:45.102589+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-04-02T00:39:45.211722+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-02T00:39:45.195923+00:00 heroku[web.1]: Process exited with status 137
2017-04-02T00:39:47.542400+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=roommate-matcher.herokuapp.com request_id=e2940321-a403-4420-9065-1851ce0f71d2 fwd="67.164.74.61" dyno= connect= service= status=503 bytes= protocol=https
2017-04-02T00:39:47.657798+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=roommate-matcher.herokuapp.com request_id=370b9dcd-cb90-4ee0-b9a8-83fbb03d229d fwd="67.164.74.61" dyno= connect= service= status=503 bytes= protocol=https
2017-04-02T00:39:48.143930+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=roommate-matcher.herokuapp.com request_id=c3aa1145-1597-48e9-9029-12a55b347501 fwd="67.164.74.61" dyno= connect= service= status=503 bytes= protocol=https

and my server file reads as:

const express = require('express');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const app = express();

const compiler = webpack(webpackConfig);
app.set('port'.process.env.PORT || 3000)

app.use(express.static(__dirname + '/public'));

app.use(webpackDevMiddleware(compiler, {
  hot: true,
  filename: 'bundle.js',
  publicPath: '/',
  stats: {
    colors: true,
  },
  historyApiFallback: true,
}));

const server = app.listen(app.get('port'), function() {
  console.log('Example app listening at http://localhost:'+port);
});

Any help appreciated!



via joanx737

No comments:

Post a Comment