Fail to connect Mongoose to Atlas

Basically you should try connecting with your url link, and specify the DB name on the mongoose connect method so if your cluster link is: mongodb+srv://userName:[email protected]/ and your DB name is: testDB then you should call the mongoose.connect method as follows: mongoose.connect(‘mongodb+srv://userName:[email protected]/’, {dbName: ‘testDB’});

How to fix ‘Error: querySrv EREFUSED’ when connecting to MongoDB Atlas?

If you’re encountering this error try to use the older connection string for Node.js 2.2.12 or later: mongodb://<username>:<password>@main-shard-00-00-03xkr.mongodb.net:27017,main-shard-00-01-03xkr.mongodb.net:27017,main-shard-00-02-03xkr.mongodb.net:27017/main?ssl=true&replicaSet=Main-shard-0&authSource=admin&retryWrites=true According to MongoDB, SRV is possibly not working due to Mongoose.