MongoDB – Can’t Connect Mongo Shell to Atlas Cluster

mongodb

There is some issue coming while connect mongo shell to the atlas cluster. It is saying that No primary detected for set Cluster0-shard-0.

ashish@ashish-Not-Specified:~$ mongo "mongodb://cluster0-shard-00-00-pth8i.mongodb.net:27017,cluster0-shard-00-01-pth8i.mongodb.net:27017,cluster0-shard-00-02-pth8i.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics
    MongoDB shell version: 3.2.17
    connecting to: mongodb://cluster0-shard-00-00-pth8i.mongodb.net:27017,cluster0-shard-00-01-pth8i.mongodb.net:27017,cluster0-shard-00-02-pth8i.mongodb.net:27017/test?replicaSet=Cluster0-shard-0
    2017-10-25T22:12:00.759+0530 I NETWORK  [thread1] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-pth8i.mongodb.net:27017,cluster0-shard-00-01-pth8i.mongodb.net:27017,cluster0-shard-00-02-pth8i.mongodb.net:27017
    2017-10-25T22:12:00.759+0530 I NETWORK  [ReplicaSetMonitorWatcher] starting
    2017-10-25T22:12:09.080+0530 W NETWORK  [thread1] No primary detected for set Cluster0-shard-0
    2017-10-25T22:12:18.389+0530 I NETWORK  [ReplicaSetMonitorWatcher] Socket recv() timeout  34.204.152.215:27017
    2017-10-25T22:12:18.610+0530 W NETWORK  [thread1] No primary detected for set Cluster0-shard-0
    2017-10-25T22:12:18.610+0530 E QUERY    [thread1] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-00-pth8i.mongodb.net:27017,cluster0-shard-00-01-pth8i.mongodb.net:27017,cluster0-shard-00-02-pth8i.mongodb.net:27017 :
    connect@src/mongo/shell/mongo.js:223:14
    @(connect):1:6

    exception: connect failed

Best Answer

@ashishkumar148, I would like to say that as per MongoDB BOL Here , MongoDB Atlas cluster only able to connect with MongoDB 3.4 version, due to Mongo Shell with TLS/SSL support.

I have gone through you mongo shell log , where i have found out that as you are using MongoDB shell version: 3.2.17.

I am also attaching the Sandbox MongoDB Cluster connect screen shot to you.

enter image description here

Note:- Before making the connection with MongoDB Atlas with MongoDB shell, make sure that you have successfully configured your IP address through Mongo Atlas IP whitelist Here .And the IP status is Active. And during the connection the User ID & Password should be used, which you have Assigned in MongoDB Atlas cluster creation time.