javascript - 赫罗库 || 错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT
问题描述
我正在尝试将我的第一个节点项目部署到 heroku,但出现此错误:
2020-09-29T04:24:09.365962+00:00 app[web.1]: production
2020-09-29T04:24:09.415266+00:00 app[web.1]: server is listening at port 40890
2020-09-29T04:24:09.942808+00:00 app[web.1]: DB connection succesfull
2020-09-29T04:25:03.400919+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-09-29T04:25:03.433351+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-09-29T04:25:03.559247+00:00 heroku[web.1]: Process exited with status 137
2020-09-29T04:25:03.607404+00:00 heroku[web.1]: State changed from starting to crashed
我正在使用 express 和 mongodb。这是我正在使用的代码:
const dotenv = require('dotenv');
const mongoose = require('mongoose');
dotenv.config({ path: './config.env' });
const app = require('./app');
require('dotenv').config();
const DB = process.env.DATABASE.replace(
'<PASSWORD>',
process.env.DATABASE_PASSWORD
);
mongoose
.connect(DB, {
useUnifiedTopology: true,
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false
})
.then(con => {
console.log('DB connection succesfull');
});
const PORT = process.env.PORT | 3000;
const server = app.listen(PORT, () => {
console.log(`server is listening at port ${PORT}`);
});
如何解决这个问题?谢谢
解决方案
这是错误端口的问题 像这样使用它
const PORT = process.env.PORT || 3000;
您的服务器在错误的端口号上启动,因此在系统检查中它无法看到您的应用程序绑定在正确的端口上
推荐阅读
- python - 带有自定义处理程序的 Python 记录器发送到 std
- css - 防止屏幕外 div 继续调整大小
- acumatica - 在 Acumatica 2019 R1 中设置自定义字段的值
- windows - 从自定义协议启动 QT 应用程序 - Windows
- javascript - 多个带有进度条的光滑滑块
- nativescript - 本机脚本
- 如何以简单的方式定义 6 行或更多行? - javascript - JavaScript:通过名称查找变量的值,这里可以接受 eval 吗?
- javascript - 是否可以从查看源页面上的 Chrome 扩展程序运行内容脚本?
- c - 使用自定义构建的 GCC 7.2.0 在 ARM64 上构建 GMP 6.1.2 - 断言错误 - BinUtils 汇编程序似乎有问题
- powerbi - 计算列或度量,用于将优先任务分组到冲刺中