4

我正在尝试将 MongoDB atlas 实例连接到 nodejs/express 服务器:

const mongoose = require("mongoose");

const dbURI =
 "mongodb+srv://(url copied from atlas connect)";

const options = {
  useNewUrlParser: true,
  dbName: "data"
};

mongoose.connect(dbURI, options).then(
 () => {
   console.log("Database connection established!");
 },
 err => {
   console.log("Error connecting Database instance due to: ", err);
 }
);

但我不断收到以下错误:

MongoNetworkError:连接 5 到集群 ... 27017 在 TLSSocket 处关闭。...

我怎样才能解决这个问题?

4

1 回答 1

6

已解决 - 检查 IP 白名单!

于 2018-10-10T20:46:15.237 回答