Heroku中的Node.js应用程序在Foreman上工作但在部署时没有?

时间:2012-08-20 03:29:39

标签: git node.js heroku foreman

我成功地让我的应用程序在foreman上运行得很好,但是一旦我将它部署到Heroku,就会在日志中抛出错误:

2012-08-20T03:22:48+00:00 heroku[web.1]: Starting process with command `node index.js`
2012-08-20T03:22:49+00:00 app[web.1]: Server has started.
2012-08-20T03:22:49+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 15134, should be 52717 (see environment variable PORT)
2012-08-20T03:22:49+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-08-20T03:22:51+00:00 heroku[web.1]: Process exited with status 137
2012-08-20T03:22:51+00:00 heroku[web.1]: State changed from starting to crashed

我试图更改它所绑定的端口,但每次我更改端口时都会更改端口。我的应用程序中还有其他错误吗?

1 个答案:

答案 0 :(得分:6)

在Heroku上,您需要使用环境变量中包含的端口: process.env.PORT