MongoDB Atlas在首次连接时无法连接到服务器

时间:2019-06-10 12:43:44

标签: node.js mongodb mongoose mongodb-atlas

我正在尝试从我的node.js应用程序连接MongoDb Atlas,但是超时,并给我报头中提到的错误。

我已经将我的IP添加到 IP白名单中。此外,我还添加了本地IP 公共IP 0.0.0.0/0 所有这三个IP都帮不了我。

这是我要连接到MongoDb Atlas的代码:

mongoose.connect('mongodb+srv://<username>:<password>@<cluster>.mongodb.net/test?retryWrites=true&w=majority', {
    useNewUrlParser: true,
    useCreateIndex: true
}).then(function () {
    console.log("Connected to DB");
}).catch(function (err) {
    console.log("ERROR : " + err.message);
});

0 个答案:

没有答案
相关问题