Heroku和我的Node/Express/MongoDB应用程序面临以下问题:
XXXX-05-10T22:56:41.782988+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=fast-depths-03410.herokuapp.com request_id=d42d214e-051d-4ba9-842f-ad98cedaf4ab fwd="xxx.xxx.xxx.xxx" dyno= connect= service= status=503 bytes= protocol=https
我在很多帖子中看到这个错误与dyno量表有关,但我认为事实并非如此。
正如你在下面的日志中看到的,该应用程序正在运行:
XXXX-05-10T22:41:56.098412+00:00 app[api.1]: yarn run v1.22.5
XXXX-05-10T22:41:56.253837+00:00 app[api.1]: $ node index.js
XXXX-05-10T22:41:57.849610+00:00 app[api.1]: server started on port 23804 (development)
但当我尝试访问我的Heroku应用程序时:https://fast-depths-03410.herokuapp.com/我唯一能看到的是
应用程序错误检查日志">
关于我的应用程序,我尝试了以下方法:
- 我已经用
heroku ps:scale {myapp-name}=1
缩放了dyno - 我已将侦听端口更改为使用
process.env.PORT
- 我在
Dockerfile
中添加了EXPOSE $PORT
问题出在哪里?如何解决?
您有正在运行的东西,但它不是web
进程。您的日志显示api
过程:
XXXX-05-10T22:41:57.849610+00:00 app[api.1]: server started on port 23804 (development)
^^^
对于非Docker部署,进程类型由Procfile
定义,并且只有web
进程可以接收来自互联网的流量。在这种情况下,从更改Procfile
api: some command
至
web: some command
以及重新部署。
如果您正在使用Docker,请确保在构建和推送映像时以及稍后发布映像时使用web
作为process-type
,例如:
heroku container:push web
heroku container:release web