Heroku Node.js错误R10(启动超时) - > Web进程在启动后60秒内无法绑定到$ PORT

时间:2015-06-27 19:10:26

标签: node.js heroku

我找到了十几种针对Express应用程序的解决方案,并设置了端口来监听。 但我有一个不使用Express的应用程序,实际上并没有听任何东西。 在成功运行60秒后,我收到一条Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch消息。 我怎么能绕过它?感谢。

4 个答案:

答案 0 :(得分:32)

经过大量的Google搜索后,我决定npm install express并添加

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

app.set('port', (process.env.PORT || 5000));

//For avoidong Heroku $PORT error
app.get('/', function(request, response) {
    var result = 'App is running'
    response.send(result);
}).listen(app.get('port'), function() {
    console.log('App is running, server is listening on port ', app.get('port'));
});

这修复了错误,即使我不喜欢添加表达只是为了避免一个错误。如果有人找到了更好的解决方案,请告诉我。

答案 1 :(得分:19)

另一种方法是使用这些命令将dynos从web(标准设置,无论Procfile中的设置)更改为worker:

heroku ps:scale web=0
heroku ps:scale worker=1

有时Heroku会忽略Procfile中的设置。

答案 2 :(得分:0)

我有同样的问题:

  

错误R10(启动超时) - > Web进程无法在启动后60秒内绑定到$ PORT

我尝试了很多东西。

以下作品不使用快递:

No operations to display at this time.

答案 3 :(得分:0)

我也遇到了同样的问题: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

在我的电脑 windows 10 Visual Studio 代码中流畅工作

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

也在package.json

中添加了这三行

"worker": "node index.js", "start": "node index.js" "test": "node test.js"

相关问题