Unable to reach primary for set Sandbox-shard-0

Hi,

I’m copying the connection string from the connect page, but getting the below error when trying to connect.

C:\Users\matthewa>mongo "mongodb+srv://sandbox-w1v19.mongodb.net/test" --username m001-student
MongoDB shell version v4.2.0
Enter password:
connecting to: mongodb://sandbox-shard-00-00-w1v19.mongodb.net:27017,sandbox-shard-00-01-w1v19.mongodb.net:27017,sandbox-shard-00-02-w1v19.mongodb.net:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Sandbox-shard-0&ssl=true
2019-09-04T17:02:01.748+1000 I  NETWORK  [js] Starting new replica set monitor for Sandbox-shard-0/sandbox-shard-00-00-w1v19.mongodb.net:27017,sandbox-shard-00-01-w1v19.mongodb.net:27017,sandbox-shard-00-02-w1v19.mongodb.net:27017
2019-09-04T17:02:01.749+1000 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-02-w1v19.mongodb.net:27017
2019-09-04T17:02:01.750+1000 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-01-w1v19.mongodb.net:27017
2019-09-04T17:02:01.750+1000 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-00-w1v19.mongodb.net:27017
2019-09-04T17:02:06.749+1000 W  NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Sandbox-shard-0
2019-09-04T17:02:08.436+1000 I  NETWORK  [js] Successfully connected to sandbox-shard-00-01-w1v19.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-w1v19.mongodb.net:27017 with a 0 second timeout)
2019-09-04T17:02:11.857+1000 W  NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Sandbox-shard-0
2019-09-04T17:02:17.125+1000 W  NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Sandbox-shard-0
2019-09-04T17:02:21.751+1000 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-00-w1v19.mongodb.net:27017
2019-09-04T17:02:22.128+1000 W  NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Sandbox-shard-0
2019-09-04T17:02:27.131+1000 W  NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Sandbox-shard-0


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


2019-09-04T17:02:27.134+1000 E  QUERY    [js] Error: Could not find host matching read preference { mode: "primary", tags: [ {} ] } for set Sandbox-shard-0 :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2019-09-04T17:02:27.137+1000 F  -        [main] exception: connect failed
2019-09-04T17:02:27.137+1000 E  -        [main] exiting with code 1

Hi @mannisbrown,

I am able to connect to your cluster without any issue. Can you please try to connect using the connection string mentioned below ?

mongo "mongodb+srv://sandbox-w1v19.mongodb.net/test" --username m001-student -p m001-mongodb-basics

If you still face any other issue then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer