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.
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:
Once you do this, you can deploy your app back on Heroku and it will work!