【问题标题】:Heroku Node Crash: at=error code=H10 desc="App crashed" method=GET path="/"Heroku 节点崩溃:at=error code=H10 desc="App crashed" method=GET path="/"
【发布时间】:2020-03-25 21:40:54
【问题描述】:

我在尝试部署我的节点应用程序时收到以下 Heroku 日志。我无法弄清楚造成这种情况的原因。我猜这与我的index.html 文件中的图标链接有关?

Heroku 日志

2020-03-25T14:07:37.323633+00:00 app[web.1]: > react-scripts start
2020-03-25T14:07:37.323633+00:00 app[web.1]: 
2020-03-25T14:07:40.667543+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.16.68.202/
2020-03-25T14:07:40.668023+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-03-25T14:07:40.668162+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-03-25T14:07:40.668280+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-03-25T14:07:40.668531+00:00 app[web.1]: Starting the development server...
2020-03-25T14:07:40.668533+00:00 app[web.1]: 
2020-03-25T14:07:40.815780+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-25T14:07:40.794329+00:00 heroku[web.1]: Process exited with status 0
2020-03-25T16:50:20.606050+00:00 heroku[web.1]: State changed from crashed to starting
2020-03-25T16:50:29.481448+00:00 heroku[web.1]: Starting process with command `npm start`
2020-03-25T16:50:32.126241+00:00 app[web.1]: npm WARN npm npm does not support Node.js v12.16.1
2020-03-25T16:50:32.126628+00:00 app[web.1]: npm WARN npm You should probably upgrade to a newer version of node as we
2020-03-25T16:50:32.126812+00:00 app[web.1]: npm WARN npm can't make any promises that npm will work with this version.
2020-03-25T16:50:32.127129+00:00 app[web.1]: npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
2020-03-25T16:50:32.127378+00:00 app[web.1]: npm WARN npm You can find the latest version at https://nodejs.org/
2020-03-25T16:50:32.263784+00:00 app[web.1]: 
2020-03-25T16:50:32.263791+00:00 app[web.1]: > project-x@0.1.0 start /app
2020-03-25T16:50:32.263792+00:00 app[web.1]: > react-scripts start
2020-03-25T16:50:32.263792+00:00 app[web.1]: 
2020-03-25T16:50:34.783181+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.18.253.226/
2020-03-25T16:50:34.783787+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-03-25T16:50:34.783888+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-03-25T16:50:34.783977+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-03-25T16:50:34.784185+00:00 app[web.1]: Starting the development server...
2020-03-25T16:50:34.784187+00:00 app[web.1]: 
2020-03-25T16:50:34.903396+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-25T16:50:34.886104+00:00 heroku[web.1]: Process exited with status 0
2020-03-25T20:32:58.790170+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hidden-stream-53835.herokuapp.com request_id=d958c692-68ad-4723-a7da-1b0fb261e74b fwd="73.60.116.154" dyno= connect= service= status=503 bytes= protocol=https
2020-03-25T20:32:59.217144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hidden-stream-53835.herokuapp.com request_id=1e9dbfb7-070b-485e-906b-a30a2e0dcc35 fwd="73.60.116.154" dyno= connect= service= status=503 bytes= protocol=https

index.html

  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />

【问题讨论】:

  • “应用程序崩溃”并没有告诉我们任何有用的信息。您的日志中还有其他内容吗?如果没有,请添加一些日志记录。
  • 我不确定日志中的哪些信息对解决此问题有用或无用。关于我正在使用的 Node 版本,我看到了另一个警告(我提供了)。我使用的是 12.16.1,但因此降级到 10.0.0。不确定这是否会导致崩溃。谢谢
  • “项目在 0.0.0.202 运行”... “项目在 0.0.0.226 运行”——这些几乎肯定是错误的。他们来自哪里?
  • 我更正了,应该是 172.16.68.202。谢谢
  • 不,不应该。它应该是 Heroku 给你的任何 IP 地址和端口。 再次,这个IP地址来自

标签: node.js heroku deployment


【解决方案1】:

任何一次分配给您的 IP 地址都会经常更改。不要专门绑定到它们。

相反,绑定到所有可用的 IP 地址,通常由0.0.0.0 表示或根本不提供 IP 地址。确保还使用 Heroku 通过 PORT 环境变量指定的端口。

假设您使用的是 Express,something like this should work

const express = require('express')
const PORT = process.env.PORT || 5000  # Fall back to port 5000 if process.env.PORT is not set

express()
  .listen(PORT, () => console.log(`Listening on ${ PORT }`))

【讨论】:

    猜你喜欢
    • 2019-07-02
    • 1970-01-01
    • 2015-03-01
    • 2013-03-30
    • 1970-01-01
    • 2020-12-13
    • 1970-01-01
    • 2018-04-09
    • 1970-01-01
    相关资源
    最近更新 更多