The trick with deploying your node.js/express app in Heroku

in #heroku6 years ago (edited)

If you are working on a simple nodejs/express service and are looking to deploy to Heroku, even though the steps to deploy are really straightforward if you are using the Heroku CLI, when you first deploy your app, you will run into an issue like this.

Screen Shot 2019-10-13 at 12.42.28 PM.png

Usually in your express code, you hard code your port number especially when you're writing a Hello World application. You mayb use a port number like 8084 or 5000. But in Heroku, you can't use the port that you want, Heroku will assign a random port for you. To use the port number that Heroku gives you, you should do the following:

Screen Shot 2019-10-13 at 12.55.48 PM.png

Once you do this, you can deploy your app back on Heroku and it will work!

Sort:  

Congratulations @sharatdotinfo! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!