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
    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 :

    exception: connect failed

3 Answers 3


@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.


It could not connect to the cluster nodes... Probably firewall was blocking access to port 27017, if the cluster was running.

  • Firewall is not blocking the 'port 27017'. Because the OP is able to run mongo shell. Oct 26, 2017 at 7:49

I currently have this challenge until I discovered that the problem was the difference between the mongo server version and the shell. I tried to connect the same mongo server with a mongo shell of the same version and it worked.

  • 1
    I'm not sure that this answers the question asked? Maybe if you want to flag it yourself as a comment - might be an idea? I know that you have to have a certain rep for comments.
    – Vérace
    Dec 9, 2017 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.