【问题标题】:Application error message when trying to open heroku app尝试打开 heroku 应用程序时出现应用程序错误消息
【发布时间】:2016-12-11 03:11:14
【问题描述】:

我是 nodejs 的新手,正在尝试将一个简单的文字游戏部署到 heroku。我按照heroku网站上的说明进行操作,直到最后一个命令“heroku open”,它都会打开一个带有以下消息的网络浏览器:

“应用程序发生错误,无法提供您的页面。请稍后再试。

如果您是应用程序所有者,请查看您的日志以了解详细信息。”

heroku 日志显示:

2016-08-04T18:56:36.552635+00:00 heroku[api]: Enable Logplex by teamsky916@gmail       .com
2016-08-04T18:56:36.552635+00:00 heroku[api]: Release v2 created by teamsky916@g       mail.com
2016-08-04T18:58:34.328360+00:00 heroku[router]: at=info code=H81 desc="Blank ap       p" method=GET path="/" host=build-word-game.herokuapp.com request_id=f238942c-ef       aa-4011-b505-7e5f062221a3 fwd="107.77.75.83" dyno= connect= service= status=502        bytes=
2016-08-04T18:58:35.171645+00:00 heroku[router]: at=info code=H81 desc="Blank ap       p" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_id=       a02c27ef-865c-48e3-91cd-bd6e29ca51e3 fwd="107.77.75.83" dyno= connect= service=        status=502 bytes=
2016-08-04T19:26:43.069903+00:00 heroku[api]: Scale to web=1 by teamsky916@gmail       .com
2016-08-04T19:26:43.070467+00:00 heroku[api]: Deploy 4725c48 by teamsky916@gmail       .com
2016-08-04T19:26:43.070552+00:00 heroku[api]: Release v3 created by teamsky916@g       mail.com
2016-08-04T19:26:43.473784+00:00 heroku[slug-compiler]: Slug compilation finishe       d
2016-08-04T19:26:43.473765+00:00 heroku[slug-compiler]: Slug compilation started
2016-08-04T19:26:45.915539+00:00 heroku[web.1]: Starting process with command `n       ode server.js`
2016-08-04T19:26:50.481084+00:00 app[web.1]: listening to port 3000!
2016-08-04T19:27:46.488886+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web        process failed to bind to $PORT within 60 seconds of launch
2016-08-04T19:27:46.488886+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-08-04T19:27:46.631684+00:00 heroku[web.1]: Process exited with status 137
2016-08-04T19:27:46.618404+00:00 heroku[web.1]: State changed from starting to c       rashed
2016-08-04T19:27:46.619564+00:00 heroku[web.1]: State changed from crashed to st       arting
2016-08-04T19:27:48.599634+00:00 heroku[web.1]: Starting process with command `n       ode server.js`
2016-08-04T19:27:51.304417+00:00 app[web.1]: listening to port 3000!
2016-08-04T19:28:48.755864+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web        process failed to bind to $PORT within 60 seconds of launch
2016-08-04T19:28:48.755938+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-08-04T19:28:48.879934+00:00 heroku[web.1]: Process exited with status 137
2016-08-04T19:28:48.893371+00:00 heroku[web.1]: State changed from starting to c       rashed
2016-08-04T19:31:31.210359+00:00 heroku[router]: at=error code=H10 desc="App cra       shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=e0536d30       -8590-453d-9a04-fb8a56eb6893 fwd="107.77.213.153" dyno= connect= service= status       =503 bytes=
2016-08-04T19:31:32.552715+00:00 heroku[router]: at=error code=H10 desc="App cra       shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_       id=89bfb417-9793-4687-b400-72cc34d16ea8 fwd="107.77.213.153" dyno= connect= serv       ice= status=503 bytes=
2016-08-04T19:53:16.445270+00:00 heroku[web.1]: State changed from crashed to st       arting
2016-08-04T19:53:18.025971+00:00 heroku[web.1]: Starting process with command `n       ode server.js`
2016-08-04T19:53:19.981109+00:00 app[web.1]: listening to port 3000!
2016-08-04T19:54:18.509309+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-08-04T19:54:18.509204+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web        process failed to bind to $PORT within 60 seconds of launch
2016-08-04T19:54:18.601875+00:00 heroku[web.1]: Process exited with status 137
2016-08-04T19:54:18.606261+00:00 heroku[web.1]: State changed from starting to c       rashed
2016-08-04T19:59:58.452903+00:00 heroku[router]: at=error code=H10 desc="App cra       shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=450b80d9       -a366-4e0f-9426-ff89eac931fb fwd="107.77.213.153" dyno= connect= service= status       =503 bytes=
2016-08-04T19:59:59.109794+00:00 heroku[router]: at=error code=H10 desc="App cra       shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_       id=1eecc47a-5334-4a38-bd8d-093a9164ead5 fwd="107.77.213.153" dyno= connect= serv       ice= status=503 bytes=
2016-08-04T20:01:28.744667+00:00 heroku[router]: at=error code=H10 desc="App cra       shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=a2d52aea       -d7fc-4f18-b023-50aa8e93587c fwd="107.77.213.153" dyno= connect= service= status       =503 bytes=
2016-08-04T20:01:29.378063+00:00 heroku[router]: at=error code=H10 desc="App cra       shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_       id=8e62ab9c-50a3-43eb-9579-9c3d4a6c9d42 fwd="107.77.213.153" dyno= connect= serv       ice= status=503 bytes=

感谢您的帮助。

【问题讨论】:

标签: node.js heroku


【解决方案1】:

您的 Node 应用程序似乎没有正常启动。这可能是因为您没有将 Node 服务器绑定到正确的端口。

在 Heroku 上,您必须将 Node 服务器绑定到 PORT 环境变量中指定的端口号。这是因为 Heroku 在具有许多其他应用程序的服务器上神奇地处理您的请求的路由。

您应该做的是修改您的 Node 代码,使其侦听端口 process.env.PORT

下面是一个监听正确端口的 Express.js 应用程序示例:

var express = require('express');

var app = express();

app.listen(process.env.PORT);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-20
    • 2020-06-27
    • 1970-01-01
    • 2013-08-10
    • 2021-01-22
    • 1970-01-01
    • 2014-09-16
    • 2019-07-28
    相关资源
    最近更新 更多