2

I am trying to deploy nodejs lite-server on Heroku. I am able to run the server fine locally, but fails on deployment with this error:

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

The basic problem is I am not sure how to allow Heroku to set the port. They do this dynamically (I only know how to do it statically). So I need to set an environmental variable so the server can set the correct port. How can I do this using lite-server?

This problem has been address for different server setups:

To configure http server port for Heroku

Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

To configure Express server port for Heroku

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

Community
  • 1
  • 1
jpat827
  • 114
  • 2
  • 9

1 Answers1

7

So I had the same issue. I ended up adding a bs-config.js file.

module.exports = {
    port: process.env.PORT,
    files: ['./**/*.{html,htm,css,js}'],
    server:{
        baseDir: "./"
    }
};

Apparently Heroku dynamically assigns a new port each time it's started. So the port can't be hard coded.

How do I run Angular.JS 2 for TypeScript on C9.io on port 8080?

Community
  • 1
  • 1
TYMG
  • 297
  • 1
  • 6
  • 14
  • Thanks, one note though, this is actually a .js script to get the port dynamically on Heroku a .json file can be used only with a static port since the port number would be hard coded. – Adam Mendoza Dec 13 '16 at 23:03