首页 > 解决方案 > Heroku - “没有网络进程正在运行”消息,但服务器已经启动

问题描述

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

我在很多帖子中看到这个错误与测功机规模有关,但我认为情况并非如此。

正如您在以下日志中看到的,该应用程序正在运行:

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/我唯一能看到的是消息

应用程序错误检查日志..."

关于我的应用程序,我尝试了以下操作:

有什么问题,我该如何解决?

标签: node.jsmongodbdockerherokumongoose

解决方案


你有一些东西在运行,但它不是一个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

并重新部署。

如果您使用webprocess-type的是 Docker,请确保在构建和推送映像时以及稍后发布时使用,例如:

heroku container:push web
heroku container:release web

推荐阅读