在Heroku上设置node.js服务器的端口 [英] Setting the port for node.js server on Heroku

查看:194
本文介绍了在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.

这篇关于在Heroku上设置node.js服务器的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆