无法连接到MongoDB Atlas集群中的任何服务器

时间:2020-08-09 23:45:50

标签: mongodb mongodb-atlas

我正在尝试使用MongoDB与我的应用程序连接,但是当我尝试在邮递员中发布内容时,我一直收到此错误。

Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you\'re trying to access the database from an IP that isn\'t whitelisted

我已将MongoDB设置为允许任何IP,并且我确认设置正确无误。

0.0.0.0/0 (includes your current IP address)

这就是我在应用程序中使用mongoose调用mongodb的方式。

mongoose.connect(
  process.env.MONGODB_URI,
  {
    useFindAndModify: true,
    useUnifiedTopology: true,
    useNewUrlParser: true,
    useCreateIndex: true,
  },
  (err) => {
    if (err) return console.log("Error: ", err);
    console.log(
      "MongoDB Connection -- Ready state is:",
      mongoose.connection.readyState
    );
  }
);

很抱歉,如果这是一个愚蠢的问题-我已经搜索了文档,并且确定丢失了一些新手显而易见的东西,但是无论我如何更改,我仍然会遇到此错误!

0 个答案:

没有答案