【问题标题】:Deploying JS app on Heroku - error status 503在 Heroku 上部署 JS 应用程序 - 错误状态 503
【发布时间】:2020-08-01 19:39:29
【问题描述】:

我准备了一个简单的应用程序来测试是否可以在 Heroku 上运行。本地似乎工作正常,不幸的是在加载一段时间后在 Heroku 上我收到“服务不可用”错误。有人可以请教这个错误的原因是什么以及如何运行这个应用程序?

Heroku local web

Locally works fine

Git 上的回购:https://github.com/tomaszchmura/OnHeroku

Error on Heroku

Heroku 日志:

2020-04-19T06:51:16.211281+00:00 app[web.1]:服务器开启 5000 2020-04-19T06:52:13.302269+00:00 heroku[web.1]:状态从开始变为崩溃 2020-04-19T09:26:59.045884+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/" host=directhero.herokuapp.com request_id=4c36cf02-2713 -4ab4-a305-67a0b20eb7c1 fwd="37.30.0.246" dyno=connect=service=status=503 bytes=protocol=https 2020-04-19T09:26:59.663890+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=directhero.herokuapp.com request_id= c5a2bd5c-740c-44d9-bb1e-9baefc20b7a7 fwd="37.30.0.246" dyno= connect= service= status=503 bytes= protocol=https 2020-04-19T09:37:12.003882+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/" host=directhero.herokuapp.com request_id=65f2621c-94ce -4241-95c5-21eac6533218 fwd="37.30.0.246" dyno=connect=service=status=503 bytes=protocol=https 2020-04-19T09:37:12.353987+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=directhero.herokuapp.com request_id= d2afcb89-48a5-4045-a838-af1cb8edd953 fwd="37.30.0.246" dyno= connect= service= status=503 bytes= protocol=https

你能建议吗?

【问题讨论】:

    标签: javascript heroku


    【解决方案1】:

    你需要监听 Heroku 在环境变量中为你提供的端口

    app.listen(process.env.PORT || 5000);
    

    之后就可以访问80端口的服务了!

    【讨论】:

    猜你喜欢
    • 2020-11-13
    • 2020-08-25
    • 2022-07-15
    • 2015-11-08
    • 1970-01-01
    • 1970-01-01
    • 2015-07-15
    • 2018-10-08
    • 2017-01-21
    相关资源
    最近更新 更多