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

我find了十几个解决快速供电的应用程序与设置端口收听。 但是我有一个不使用Express的应用程序,实际上并没有监听任何东西。 并且在成功运行60秒后,我得到一个Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch消息的Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 。 我如何解决它? 谢谢。

大量的谷歌search后,我决定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')); }); 

这固定的错误,即使我不喜欢添加快递只是为了避免一个错误。 如果有人find更好的解决scheme,请让我知道。

如果你的应用程序不听任何端口,那么你应该使用另一种types的应用程序在你的Procfile,我的意思是在Procfile中有:

 web: node app.js 

将其replace为:

 worker: node app.js 

“web”types的应用程序意味着您的应用程序必须监听某个端口

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

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

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

我有同样的问题:

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

我尝试了很多东西。

以下作品不使用快递:

 http.createServer(onRequest).listen(process.env.PORT || 6000)