11

我试图运行我的 nodejs 应用程序[使用 socket.io]。我部署它没有错误。但是当我运行它时,我得到了这个:

2013-09-07T01:13:09.697674+00:00 heroku[api]: Release v2 created by vietminhle98@gmail.com
2013-09-07T12:15:57.148172+00:00 heroku[router]: at=info code= desc="Blank app" method=GET 

    path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=502 bytes=
2013-09-07T12:15:57.672631+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=502 bytes=
2013-09-08T01:14:00+00:00 heroku[slug-compiler]: Slug compilation started
2013-09-08T01:14:28.327510+00:00 heroku[api]: Scale to web=1 by vietminhle98@gmail.com
2013-09-08T01:14:28.351861+00:00 heroku[api]: Add PATH config by vietminhle98@gmail.com
2013-09-08T01:14:28.382733+00:00 heroku[api]: Release v3 created by vietminhle98@gmail.com
2013-09-08T01:14:28.426015+00:00 heroku[api]: Deploy 6be3e0c by vietminhle98@gmail.com
2013-09-08T01:14:28.439849+00:00 heroku[api]: Release v4 created by vietminhle98@gmail.com
2013-09-08T01:14:28+00:00 heroku[slug-compiler]: Slug compilation finished
2013-09-08T01:14:32.477748+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-09-08T01:14:34.751076+00:00 app[web.1]: LISTENING
2013-09-08T01:14:35.314545+00:00 app[web.1]: info: socket.io started
2013-09-08T01:15:34.427477+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-09-08T01:15:34.427784+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-08T01:15:35.676986+00:00 heroku[web.1]: State changed from starting to crashed
2013-09-08T01:15:35.676986+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-08T01:15:35.663597+00:00 heroku[web.1]: Process exited with status 137
2013-09-08T01:15:37.774955+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-09-08T01:15:38.653254+00:00 app[web.1]: LISTENING
2013-09-08T01:15:38.755820+00:00 app[web.1]: info: socket.io started
2013-09-08T01:15:59.434156+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:16:27.246666+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:16:38.781151+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-09-08T01:16:38.781376+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-08T01:16:39.983421+00:00 heroku[web.1]: Process exited with status 137
2013-09-08T01:16:40.011325+00:00 heroku[web.1]: State changed from starting to crashed
2013-09-08T01:16:41.541487+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:18:44.971726+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:18:47.279357+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:20:09.452479+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:20:08.839678+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:26:06.279799+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-08T01:26:08.503114+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-09-08T01:26:09.522676+00:00 app[web.1]: LISTENING
2013-09-08T01:26:09.656509+00:00 app[web.1]: info: socket.io started
2013-09-08T01:27:09.615998+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-09-08T01:27:09.616415+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-08T01:27:10.895911+00:00 heroku[web.1]: Process exited with status 137
2013-09-08T01:27:10.909789+00:00 heroku[web.1]: State changed from starting to crashed
2013-09-08T01:27:13.347426+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:27:14.033545+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:28:02.549578+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:28:06.335482+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/index.html host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:28:07.041450+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= serv
ice= status=503 bytes=
2013-09-08T01:34:23.479191+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/index.html host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:34:24.942938+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:34:29.678584+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:34:29.090141+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:36:38.073605+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-08T01:36:41.051197+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-09-08T01:36:42.526835+00:00 app[web.1]: LISTENING
2013-09-08T01:36:42.927958+00:00 app[web.1]: info: socket.io started
2013-09-08T01:37:02.906047+00:00 heroku[api]: Scale to web=1 by vietminhle98@gmail.com
2013-09-08T01:37:43.000152+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-09-08T01:37:43.000399+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-08T01:37:44.751965+00:00 heroku[web.1]: Process exited with status 137
2013-09-08T01:37:44.766078+00:00 heroku[web.1]: State changed from starting to crashed
2013-09-08T01:45:39.155699+00:00 heroku[api]: Starting process with command `rake db:migrate` by vietminhle98@gmail.com
2013-09-08T01:45:41.607954+00:00 heroku[run.2140]: Awaiting client
2013-09-08T01:45:42.584829+00:00 heroku[run.2140]: Starting process with command `rake db:migrate`
2013-09-08T01:45:43.920789+00:00 heroku[run.2140]: Process exited with status 1
2013-09-08T01:45:43.935727+00:00 heroku[run.2140]: State changed from starting to complete
2013-09-08T01:46:55.968060+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-08T01:46:58.347733+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-09-08T01:47:00.425372+00:00 app[web.1]: LISTENING
2013-09-08T01:47:00.582876+00:00 app[web.1]: info: socket.io started
2013-09-08T01:47:59.952712+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-08T01:47:59.952459+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-09-08T01:48:01.523065+00:00 heroku[web.1]: Process exited with status 137
2013-09-08T01:49:02.687355+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:49:03.561165+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:48:01.532500+00:00 heroku[web.1]: State changed from starting to crashed
2013-09-08T01:50:30.232096+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:50:29.121508+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:50:49.246283+00:00 heroku[web.1]: State changed from crashed to starting
2013-09-08T01:50:51.161871+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-09-08T01:50:51.827825+00:00 app[web.1]: LISTENING
2013-09-08T01:50:51.945835+00:00 app[web.1]: info: socket.io started
2013-09-08T01:51:51.972737+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-09-08T01:51:51.972975+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-08T01:51:53.141508+00:00 heroku[web.1]: Process exited with status 137
2013-09-08T01:51:53.152332+00:00 heroku[web.1]: State changed from starting to crashed
2013-09-08T01:51:54.484616+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:51:55.899914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:52:19.791497+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:52:20.616151+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:52:39.086637+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:52:39.688008+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:51:54.508738+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:51:55.281138+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:54:03.778339+00:00 heroku[api]: Starting process with command `bash` by vietminhle98@gmail.com
2013-09-08T01:54:07.822098+00:00 heroku[run.9425]: Awaiting client
2013-09-08T01:54:07.856807+00:00 heroku[run.9425]: Starting process with command `bash`
2013-09-08T01:54:08.924087+00:00 heroku[run.9425]: State changed from starting to up
2013-09-08T01:54:24.533998+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:54:25.693218+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:54:28.098195+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:54:28.648493+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=
2013-09-08T01:56:27.247187+00:00 heroku[run.9425]: Process exited with status 1
2013-09-08T01:56:27.257609+00:00 heroku[run.9425]: State changed from up to complete

这就是完整的日志。我扫描了它,发现了3个错误: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

at=error code=H20 desc="App boot timeout" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=

at=error code=H10 desc="App crashed" method=GET path=/ host=fnboard.herokuapp.com fwd="122.109.112.187" dyno= connect= service= status=503 bytes=

我不知道为什么这三个错误同时发生,我不知道我的应用程序出了什么问题,请帮忙

我的package.json:

{
"name": "fnBoard",
  "version": "0.0.1",
  "private": true,
  "scripts": {
  "start": "node server.js"
 },
  "dependencies": {
    "socket.io": "0.9.x"
  },
    "engines": {
     "node": "0.10.x",
     "npm": "1.3.x"
  }
}

档案:

web: node server.js

.gitignore:

node_modules
4

4 回答 4

27

您的一份日志说:

2013-09-08T01:15:34.427477+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

要解决此问题,请使用以下端口号:

var port_number = server.listen(process.env.PORT || 3000);
app.listen(port_number);

Heroku 为您的应用程序设置一个动态分配的端口号。因此,如果您严格指定要使用的端口号,Heroku 将无法做到这一点。

但是,您应该设置一个端口号,以便您的应用可以在localhost. 因此,pipe到指定的端口号'3000'。

从 Heroku + node.js 错误中找到了这个答案(Web 进程在启动后 60 秒内无法绑定到 $PORT)

于 2014-02-19T06:45:35.477 回答
4

也许你错误的监听端口?检查您的应用程序端口,查找是否设置为process.env.PORT || 3000.

于 2013-12-28T11:27:50.980 回答
2

当我在 package.json 中编写错误命令时出现此错误:我写道:

"scripts" : {
  "start": "index.js"
}

代替 :

"scripts" : {
  "start": "node index.js"
}

当我写 node index.js 时,我已经准备好了。

于 2018-07-24T10:31:13.707 回答
1

收听 127.0.0.1 会导致我们出现code=H20 desc="App boot timeout"问题。将监听地址改为 0.0.0.0 即可解决问题。

另外,不要使用您自己的端口,而是使用环境变量 PORT,它由 heroku 传递给您的应用程序环境变量。否则,你也会遇到这个问题。

这是我们的节点代码:

const { PORT=3000, LOCAL_ADDRESS='0.0.0.0' } = process.env
server.listen(PORT, LOCAL_ADDRESS, () => {
  const address = server.address();
  console.log('server listening at', address);
});

因此,请尝试记录您的侦听地址和端口并首先检查它们。

于 2020-04-07T05:09:35.667 回答