【问题标题】:MongoTimeoutError: Server selection timed out after 30000 ms, using heroku to deployMongoTimeoutError: Server selection timed out after 30000 ms, 使用heroku部署
【发布时间】:2020-07-27 14:17:39
【问题描述】:

我需要你的帮助来将我的 mongodb 数据库连接到集群图集,我配置了我的 IP、用户名和密码。我正在使用heroku进行部署。感谢帮助!但我不能,见下文:

表达:“^4.17.1”, 快速会话:“^1.17.0”, 猫鼬:“^5.8.3”,

const mongoose = require('mongoose');
const db = { mongoURI: 'mongodb+srv://username:password@blog-prod-upfzz.mongodb.net/test?retryWrites=true&w=majority' }    
    mongoose.Promise = global.Promise;
    mongoose.connect(db.mongoURI, {
      useUnifiedTopology: true,
      useNewUrlParser: true
      }).then(() => {
        console.log('Successfully');
      }).catch((err) => {
        console.log('Error: ' + err);
      });

【问题讨论】:

标签: javascript node.js mongodb express mongoose


【解决方案1】:

我已将我的 IP 添加到白名单和任何地方的 IP 但无法正常工作。我阅读了链接,但我不明白它对我有什么帮助,对不起..

【讨论】:

    【解决方案2】:

    您需要将服务器 IP 列入白名单。请参阅here,了解如何确定将哪些 IP 列入白名单。

    【讨论】:

      猜你喜欢
      • 2020-07-15
      • 2016-08-21
      • 2019-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-08
      相关资源
      最近更新 更多