Reputation: 21
const mongoose = require('mongoose');
mongoose.connect('mongodb://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net:27017/djsdashboard/?authSource=admin', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
Error : UnhandledPromiseRejectionWarning: 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
and i dont know how to fix it please Help
If you want more information just ask for it specifically!
mongodb+srv://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net/admin?retryWrites=true&w=majority gives the error :
(node:7288) UnhandledPromiseRejectionWarning: Error: querySrv ENOTFOUND _mongodb._tcp.mee6copycluster-shard-00-00.r86qy.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19)
(node:7288) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7288) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Upvotes: 1
Views: 3433
Reputation: 331
I had the same issue and I resolved it by simply selecting "Allow access from anywhere" button in "Network Access" section in my MongoDB dashboard.
It can be due to connections via VPNs or Proxies.
Now you can connect to the corresponding server and the Port you've specified.
Upvotes: 2
Reputation: 21
Fixed it :
mongoose.connect('mongodb://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net:27017,mee6copycluster-shard-00-01.r86qy.mongodb.net:27017,mee6copycluster-shard-00-02.r86qy.mongodb.net:27017/djsdashboard?ssl=true&replicaSet=atlas-5r6qbu-shard-0&authSource=admin&retryWrites=true&w=majority', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
That fixed it for me
Upvotes: 0