The trick with deploying your node.js apps to Heroku

By 0xgult | 0xgult | 13 Oct 2019


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.

351665157-9e12f6876e52f4cc1474f655247b469ea39407f32adb0c97dba3cdd97b20b5f8.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:

351665157-e14994e294deff9b68a0a23373bf5f6f98c2bdec45e4a3e06134cced225c46c4.png

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

How do you rate this article?


0

0

0xgult
0xgult

I write crypto things!


0xgult
0xgult

This blog will be a general category blog. If my content doesn’t fall into any of my specialized blog categories, it will go here.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.