Setting the $PORT variable on heroku

config, heroku, networking, port, tcp

Solution

You cannot change the assigned port. If you bind to any other port than the assigned one, we will kill your process with an R11 error code

Problem

On heroku, there is a variable named $PORT This is randomly generated every time heroku starts an application. Is there any way to set it so it will stay the same on startup? NOTE: I tried heroku config:set and config:add but unless I'm doing it wrong, it hasn't taken effect. Any help appreciated.

Original source