I am seeing similar posts, however none are helping me solve my problem.
Following a Udemy tutorial that builds a MERN application from scratch, I got stuck on the mongoose connection.
Here is my index.js code:
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");
});
Here is the error I am getting:
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/
As stated, I am seeing similar errors relating to an IP that isn't whitelisted.
However, in my mongoDB account, it seems that my IP is already whitelisted:
In the screenshot above, the blank part is where my IP is located (right before it says "includes your current IP address").
Since my IP is listed there, does that not mean my IP is whitelisted?
If not, how do I whitelist my IP?
question from:
https://stackoverflow.com/questions/65948083/mongodb-whitelist-ip 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…