Can I have node.js listen on a non-standard port when hosted on Heroku?

后端 未结 1 1141
后悔当初
后悔当初 2021-01-19 05:26

I\'m building a node.js app and am experimenting with hosting it on Heroku. It seems that to make my app available to the world, I need to listen like this:

ap

相关标签:
1条回答
  • 2021-01-19 05:36

    No. Heroku tells your application which port your application is required to listen on. The required interface between Heroku and your application is the PORT environment variable: your application must look for and use it. Your application is not able to listen on any other port except the port that Heroku tells your application it must listen on. Heroku tries to open a TCP connection to your application on that port and, if sixty seconds elapse since Heroku started your application and your application isn't listening on that port, Heroku figures your application is broken and shuts it down.

    0 讨论(0)
提交回复
热议问题