gpt4 book ai didi

Node.js 和 MongoDB Atlas Mongoose 连接错误

转载 作者:可可西里 更新时间:2023-11-01 09:33:11 26 4
gpt4 key购买 nike

我正在尝试将 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: connection 5 to cluster ... 27017 closes at TLSSocket. ...

我该如何解决这个问题?

最佳答案

已解决——检查IP白名单!

关于Node.js 和 MongoDB Atlas Mongoose 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52582674/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com