Unable to connect using mongo shell

$ mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

MongoDB shell version v3.6.13

connecting to: mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0

2019-06-27T13:39:45.953-0700 I NETWORK [thread1] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017

2019-06-27T13:39:46.249-0700 I NETWORK [thread1] Successfully connected to cluster0-shard-00-00-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-jxeqq.mongodb.net:27017 with a 5 second timeout)

2019-06-27T13:39:51.334-0700 W NETWORK [thread1] Failed to connect to 34.205.152.216:27017 after 5000ms milliseconds, giving up.

2019-06-27T13:39:56.353-0700 W NETWORK [thread1] Failed to connect to 52.4.238.74:27017 after 5000ms milliseconds, giving up.

2019-06-27T13:39:56.353-0700 W NETWORK [thread1] Unable to reach primary for set Cluster0-shard-0

2019-06-27T13:39:56.627-0700 I NETWORK [thread1] Successfully connected to cluster0-shard-00-00-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-jxeqq.mongodb.net:27017 with a 0 second timeout)

2019-06-27T13:40:01.921-0700 W NETWORK [thread1] Failed to connect to 34.205.152.216:27017 after 5000ms milliseconds, giving up.

2019-06-27T13:40:06.922-0700 W NETWORK [thread1] Failed to connect to 52.4.238.74:27017 after 5000ms milliseconds, giving up.

2019-06-27T13:40:06.923-0700 W NETWORK [thread1] Unable to reach primary for set Cluster0-shard-0

2019-06-27T13:40:12.497-0700 W NETWORK [thread1] Failed to connect to 34.205.152.216:27017 after 5000ms milliseconds, giving up.

2019-06-27T13:40:17.500-0700 W NETWORK [thread1] Failed to connect to 52.4.238.74:27017 after 5000ms milliseconds, giving up.

2019-06-27T13:40:17.501-0700 W NETWORK [thread1] Unable to reach primary for set Cluster0-shard-0

2019-06-27T13:40:17.501-0700 E QUERY [thread1] Error: Could not find host matching read preference { mode: “primary”, tags: [ {} ] } for set Cluster0-shard-0 :

connect@src/mongo/shell/mongo.js:263:13

@(connect):1:6

exception: connect failed

It seems like something is wrong on the server side. I was able to use Compass to connect but not with Mongo Shell.

I am able to connect with your command
May be temporary N/W issues or firewall blocking your connection

1 Like

I got this error:

$ mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.0.10
exception: No digits

I have this error, seems some problem with the SSL:
MongoDB shell version v4.0.10
connecting to: mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0
2019-06-29T01:38:06.104+0100 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017
2019-06-29T01:38:21.423+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-06-29T01:38:21.443+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-06-29T01:38:21.446+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-06-29T01:38:21.447+0100 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.

*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2019-06-29T01:38:21.454+0100 E QUERY [js] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

Are you able to ping cluster0-shard-00-00-jxeqq.mongodb.net
Check there are no firewall/anti virus issues
Are you trying from office or home?
Try from another location
Did you whitelist the IP

“certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider”

Thanks ramachandra_37567,

It was the firewall :smiley:

Antonio Silva

I was able to connect from home, so probably was FW from office. Thanks.