在Heroku上设置node.js服务器的端口

在Heroku上设置node.js服务器的端口

问题描述:

我启动了一个node.js服务器,具有以下一行来设置端口:

I launched a node.js server with the following line to set the port:

app.set('port', process.env.PORT || 8080);

这意味着,它应该读PORT env变量或默认为8080,它在本地运行。他们都不是在Heroku上发生的,服务器总是使用默认端口80.任何想法如何更改?

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设置你应该绑定的PORT变量,并监听tcp / 80。

You can't. Heroku sets the PORT variable that you are supposed to bind, and listens on tcp/80.