gpt4 book ai didi

git - Heroku 中的 Node.js 应用程序可以在 Foreman 上运行但在部署时不起作用?

转载 作者:搜寻专家 更新时间:2023-11-01 00:18:59 26 4
gpt4 key购买 nike

我成功地让我的应用程序在 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

我曾尝试更改它绑定(bind)到的端口,但每次我这样做时它都会再次更改端口。我的应用程序是否还有其他问题?

最佳答案

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

关于git - Heroku 中的 Node.js 应用程序可以在 Foreman 上运行但在部署时不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12031990/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com