繁体   English   中英

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

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

我正在尝试将我的第一个节点项目部署到 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;

您的服务器在错误的端口号上启动,因此在系统检查时无法看到您的应用程序绑定在正确的端口上

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM