node.js - Heroku Node 503

标签 node.js heroku http-status-code-503

我正在创建一个非常简单的 Heroku NodeJS 服务器,当我加载页面时它抛出以下错误:

Failed to load resource: the server responded with a status of 503 (Service Unavailable)

index.js 文件的代码:

const express = require('express');
const app = express();


app.get('/', (request, res) => {
    res.send('Conneccteedd!!')
    }
)

app.get('/something', (request, res) => {
    res.send('somethingg!!')
    }
)

app.listen(3000, () => console.log('Example app listening on post 3000!'))

当我运行 heroku log 时,我得到以下信息:

2018-04-07T17:23:59.443080+00:00 app[api]: Enable Logplex by user rcocuzzo8@gmail.com
2018-04-07T17:23:59.139900+00:00 app[api]: Release v1 created by user rcocuzzo8@gmail.com
2018-04-07T17:23:59.139900+00:00 app[api]: Initial release by user rcocuzzo8@gmail.com
2018-04-07T17:23:59.443080+00:00 app[api]: Release v2 created by user rcocuzzo8@gmail.com
2018-04-07T17:24:44.000000+00:00 app[api]: Build started by user rcocuzzo8@gmail.com
2018-04-07T17:24:52.198560+00:00 app[api]: Deploy ac13e171 by user rcocuzzo8@gmail.com
2018-04-07T17:24:52.198560+00:00 app[api]: Release v3 created by user rcocuzzo8@gmail.com
2018-04-07T17:24:52.225795+00:00 app[api]: Scaled to web@1:Free by user rcocuzzo8@gmail.com
2018-04-07T17:24:44.000000+00:00 app[api]: Build succeeded
2018-04-07T17:24:54.670733+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-07T17:24:57.221082+00:00 heroku[web.1]: Process exited with status 1
2018-04-07T17:24:57.237275+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-07T17:24:57.240098+00:00 heroku[web.1]: State changed from crashed to starting
2018-04-07T17:24:57.159083+00:00 app[web.1]: npm ERR! missing script: start
2018-04-07T17:24:57.165086+00:00 app[web.1]: 
2018-04-07T17:24:57.165114+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-04-07T17:24:57.165210+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-04-07T17_24_57_160Z-debug.log
2018-04-07T17:25:00.031630+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-07T17:25:02.926871+00:00 heroku[web.1]: Process exited with status 1
2018-04-07T17:25:02.833143+00:00 app[web.1]: npm ERR! missing script: start
2018-04-07T17:25:02.842169+00:00 app[web.1]: 
2018-04-07T17:25:02.842516+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-04-07T17:25:02.842705+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-04-07T17_25_02_835Z-debug.log
2018-04-07T17:25:02.943109+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-07T17:25:33.768543+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-crag-38927.herokuapp.com request_id=604adedc-92bb-41f9-aff8-510ef9540502 fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:25:34.409195+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-crag-38927.herokuapp.com request_id=0e875c22-57c7-4222-88b7-182580dc5aca fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:25:52.739291+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-crag-38927.herokuapp.com request_id=68de943d-1ec9-4b58-8c2a-1b02f330746c fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:25:53.528379+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-crag-38927.herokuapp.com request_id=b6b7cf31-64e7-4888-9eb9-42fe65b4f9c0 fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:27:33.130652+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-crag-38927.herokuapp.com request_id=9c3180f6-76fa-40f1-98b4-d39018991e96 fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:27:33.494007+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-crag-38927.herokuapp.com request_id=3841d1fa-d1ca-482c-8f43-947f07e4f84d fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:33:42.000000+00:00 app[api]: Build started by user rcocuzzo8@gmail.com
2018-04-07T17:33:52.608615+00:00 app[api]: Deploy 9d2bc566 by user rcocuzzo8@gmail.com
2018-04-07T17:33:52.608615+00:00 app[api]: Release v4 created by user rcocuzzo8@gmail.com
2018-04-07T17:33:42.000000+00:00 app[api]: Build succeeded
2018-04-07T17:33:54.281891+00:00 heroku[web.1]: State changed from crashed to starting
2018-04-07T17:33:57.242836+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-07T17:33:59.949160+00:00 app[web.1]: 
2018-04-07T17:33:59.949177+00:00 app[web.1]: > first@1.0.0 start /app
2018-04-07T17:33:59.949179+00:00 app[web.1]: > node index.js
2018-04-07T17:33:59.949181+00:00 app[web.1]: 
2018-04-07T17:34:00.317195+00:00 app[web.1]: Example app listening on post 3000!
2018-04-07T17:34:57.440018+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-04-07T17:34:57.440165+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-04-07T17:34:57.554675+00:00 heroku[web.1]: Process exited with status 137
2018-04-07T17:34:57.575996+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-07T17:35:07.163337+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-crag-38927.herokuapp.com request_id=872ac12e-8d25-40c9-a6c8-304a6e8aab42 fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:35:07.584580+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-crag-38927.herokuapp.com request_id=0534531c-1a76-46a9-9fc0-54c0c814387e fwd="73.178.82.243" dyno= connect= service= status=503 bytes= protocol=https
2018-04-07T17:44:18.000000+00:00 app[api]: Build started by user rcocuzzo8@gmail.com
2018-04-07T17:44:27.830483+00:00 heroku[web.1]: State changed from crashed to starting
2018-04-07T17:44:27.611180+00:00 app[api]: Release v5 created by user rcocuzzo8@gmail.com
2018-04-07T17:44:27.611180+00:00 app[api]: Deploy f1d3f52b by user rcocuzzo8@gmail.com
2018-04-07T17:44:18.000000+00:00 app[api]: Build succeeded
2018-04-07T17:44:29.667502+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-07T17:44:32.132423+00:00 app[web.1]: 
2018-04-07T17:44:32.132444+00:00 app[web.1]: > first@1.0.0 start /app
2018-04-07T17:44:32.132445+00:00 app[web.1]: > node index.js
2018-04-07T17:44:32.132446+00:00 app[web.1]: 
2018-04-07T17:44:32.322170+00:00 app[web.1]: Example app listening on post 3000!

它似乎指向缺少 start 测试,但这是我的 package.json 文件(其中包含脚本):

{
  "name": "first",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Rcuz8/express-server-01.git"
  },
  "author": "cocuzzo",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/Rcuz8/express-server-01/issues"
  },
  "homepage": "https://github.com/Rcuz8/express-server-01#readme",
  "dependencies": {
    "express": "^4.16.3"
  }
}

最后,这是打开控制台后网站的样子:

如果您想要更好的代码视觉效果:here是 GitHub

最佳答案

来自评论: 为什么端口3000? Heroku 如何知道将流量代理到该端口?

关于node.js - Heroku Node 503,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49710370/

相关文章:

node.js - 如何使用 Mocha 测试带有 Passport Google OAuth 身份验证的 Express REST API?

javascript - rails : CSS/Javascript working fine locally but not on Heroku

Node.js API 在本地工作但不在 Heroku 上工作

服务器过载的 HTTP 状态代码

mongodb - 连接到 mLab 上的 MongoDB 数据库身份验证失败

docker - Haproxy 和间歇性 503 问题

node.js - 如何保证最新的写入不会被之前的写入覆盖

node.js - Electron 包 - 如何写入/读取文件

javascript - 如何在 Node 中使用 x.509 证书验证 JWT token ?

heroku - 将 Heroku 应用程序链接到 Github 存储库。为了什么?