I launched a node.js server with the following line to set the port:
app.set('port', process.env.PORT || 8080);
This means that, it should either read the PORT env variable or default to 8080, as it does when it's run locally. Neither of them is happening on Heroku, and the server always uses the default port 80. Any idea how to change it?
heroku config
PORT: 8080
Heroku treats web apps just like any other app and doesn't allow you to assign listening ports directly. Your web server will be assigned a dynamic port by Heroku but to ACCESS it, you will need to use the default port (80).
Reference: Heroku Runtime Principles - Web Servers
You should use the port opened by heroku like so:
It sets the port to 80 if it has somehow not been set already
In my case, heroku was listening on the default HTTPS port:
443
and it was not visible viaheroku config:get PORT
.You can't. Heroku sets the PORT variable that you are supposed to bind, and listens on tcp/80.