Web process failed to bind to $PORT within 60 seconds of launch"-6ren"> Web process failed to bind to $PORT within 60 seconds of launch"-我正在使用 Express 在 NodeJS 上开发 API,在尝试将其部署到 Heroku 时遇到此错误: Error R10 (Boot timeout) -> Web process faile-6ren">
gpt4 book ai didi

node.js - 在 Nodejs 上获取 "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch"

转载 作者:太空宇宙 更新时间:2023-11-03 23:26:44 25 4
gpt4 key购买 nike

我正在使用 Express 在 NodeJS 上开发 API,在尝试将其部署到 Heroku 时遇到此错误:

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

我正在使用 process.env.PORT 变量,正如我在此处找到的那样,但它仍然无法正常工作。这是index.js代码:

var express = require('express');
var app = express();
var bodyParser = require("body-parser");
app.use(bodyParser.json());
var router = require("./router");
app.use('/viatges', router);

app.listen(3000 || process.env.PORT,function(){
console.log("up and running on port "+process.env.PORT);
});

您知道是什么原因导致此问题吗?

在heroku日志上我看到这一行

2017-04-01T11:44:07.091181+00:00 app[web.1]: up and running on port 27583

所以我假设 PORT 环境变量已正确设置...

最佳答案

没关系,我刚刚修复了它。我更改了 OR 中操作数的顺序,我假设 javascript 只是按照定义的第一个操作数进行操作。

现在看起来像这样:

app.listen(process.env.PORT || 3000 ,function(){
console.log("up and running on port "+process.env.PORT);
});

关于node.js - 在 Nodejs 上获取 "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43156498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com