我正在尝试将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中关闭。 ...
我该如何解决?
答案 0 :(得分:3)
已解决-检查IP白名单!