问题描述
我看到了类似的帖子,但没有一个能帮助我解决问题。
按照从头开始构建 MERN 应用程序的 Udemy 教程,我卡在猫鼬连接上。
这是我的 index.js 代码:
const express = require("express");
const mongoose = require("mongoose");
const app = express();
app.use(express.json());
app.listen(5000,() => console.log("Server started on port 5000"));
app.use("/snippet",require("./routers/snippetRouter"));
mongoose.connect("mongodb+srv://snippetUser:_password_@
snippet-manager.sometext.mongodb.net/main?retryWrites=
true&w=majority",{
useNewUrlParser: true,useUnifiedTopology: true
},(err) => {
if (err) return console.log("error here " + err);
console.log("Connected to MongoDB");
});
这是我得到的错误:
Server started on port 5000
error here MongooseServerSelectionError: 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. Make sure your current IP address is on your Atlas
cluster's IP whitelist:
https://docs.atlas.mongodb.com/security-whitelist/
如上所述,我看到与未列入白名单的 IP 相关的类似错误。
然而,在我的mongoDB账户中,我的IP似乎已经被列入白名单:
在上面的屏幕截图中,空白部分是我的 IP 所在的位置(就在它说“包括您当前的 IP 地址”之前)。
既然我的 IP 列在那里,那不就意味着我的 IP 被列入白名单了吗?
如果没有,我如何将我的 IP 列入白名单?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)