Heroku Node.js 错误 R10(启动超时)->Web 进程未能在启动后 60 秒内绑定到 $PORT [英] Heroku Node.js Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

查看:27
本文介绍了Heroku Node.js 错误 R10(启动超时)->Web 进程未能在启动后 60 秒内绑定到 $PORT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 Express 驱动的应用程序找到了十几种解决方案,并设置了侦听端口.但我有一个不使用 Express 的应用程序,而且实际上什么也不听.在它成功运行 60 秒后,我收到一个 Error R10(启动超时)->Web 进程未能在启动 60 秒内绑定到 $PORT 消息.我怎样才能解决它?谢谢.

I found a dozen solutions for Express powered apps with setting port to listen on. But I have an app that doesn't use Express and doesn't in fact listens anything. And after 60 seconds of it successfully running I get a Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch message. How I can get around it? Thanks.

推荐答案

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

After lots of googling I decided to npm install express and add

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'));
});

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

This fixed the error, even though I don't like adding express just to avoid one error. If someone finds a better solution, please let me know.

这篇关于Heroku Node.js 错误 R10(启动超时)->Web 进程未能在启动后 60 秒内绑定到 $PORT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆