Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

MongooseServerSelectionError: Unable to connect to MongoDB Atlas despite whitelisting IP

$
0
0

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:

TopologyDescription {  type: 'ReplicaSetNoPrimary',  servers: Map(3) {'cluster0-shard-00-01.s4p3d.mongodb.net:27017' => [ServerDescription],'cluster0-shard-00-00.s4p3d.mongodb.net:27017' => [ServerDescription],'cluster0-shard-00-02.s4p3d.mongodb.net:27017' => [ServerDescription]  },  setName: 'atlas-1xlvhi-shard-0',  heartbeatFrequencyMS: 10000,  localThresholdMS: 15,}this is the codeconst mongoose = require("mongoose");const DBConnect = async () => {    await mongoose.connect('mongodb+srv://<username>:<password>@cluster0.s4p3d.mongodb.net/<dbname>', {        useNewUrlParser: true,        useUnifiedTopology: true,    });};DBConnect()  .then(() => console.log("DB Connected"))  .catch((err) => console.log("DB Not Connected", err));

Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>