Connecting to Atlas from Sandbox

The connection string never appeared, so I used the string from class given below:

mongo “mongodb://sandbox-shard-00-00-8orqd.mongodb.net:27017,sandbox-shard-00-01-8orqd.mongodb.net:27017,sandbox-shard-00-02-8orqd.mongodb.net:27017/test?replicaSet=Sandbox-Shard-0” --authenticationDatabase admin --ssl --username m001-student --password m001-mongob-basics

The connection failed with the following error message and I think I should modify the above string

2019-09-30T14:16:15.370-0400 E QUERY [js] Error: connect failed to replica set Sandbox-Shard-0/sandbox-shard-00-00-8orqd.mongodb.net:27017,sandbox-shard-00-01-8orqd.mongodb.net:27017,sandbox-shard-00-02-8orqd.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2019-09-30T14:16:15.374-0400 F - [main] exception: connect failed
2019-09-30T14:16:15.374-0400 E - [main] exiting with code 1

Have you created your sandbox cluster?Is it up and running
What does status show in Atlas
Unable to connect
2019-10-01T08:38:41.525+0530 W NETWORK [js] Unable to reach primary for set sandbox-shard-0
2019-10-01T08:38:41.527+0530 I NETWORK [js] Cannot reach any nodes for set sandbox-shard-0. Please check network connectivity and the status of the set. This has happened for 9 checks in a row.
2019-10-01T08:38:42.304+0530 W NETWORK [js] node: sandbox-shard-00-01-8orqd.mongodb.net:27017 isn’t a part of set:

A typo: It should be connecting to Sandbox Atlas cluster from mongo shell

I couldn’t find the string, the instructor used, from my windows 10 environment, that I had written previously, because I wasn’t able to connect. The string was just not there in 4.2.
Instead I used the following string that was there and I entered the password manually. I used:
mongo “mongodb+srv://sandbox-hvtwd.mongodb.net/test” --username m001-student
and I got the following prompt:
MongoDB Enterprise Sandbox-shard-0:PRIMARY>

But I’m not able to run most of the queries, demonstrated in class like:
db.movies.find({cast: [“Jeff Bridges”, “Tim Robbins”]}).pretty()
I see the collection, movieDetails but it does nothing.
I think the string I used to connect is wrong. Please could you give me the correct string to connect to Sandbox.

I also tried jxeqq instead of 8oqq the instructor used above, but was still not able to connect

sorry for the typo: The instructor’s string contained 8orqd and not 8oqq

Hi @charles_89592,

In our classes we have used two different atlas clusters. One is the Atlas class cluster and other is Sandbox cluster. Whenever you are following any lectures or doing any labs, please make sure you are connected to the right cluster.

You are not able to run this query because you are connected to the wrong cluster. In order to be able to run this query you are supposed to be connected to the Atlas class cluster.

The connection string for connecting to the Atlas classc cluster is :

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Based on what you have shared above, I believe this is you Sandbox cluster connection string :

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

Sandbox cluster is owned by you and you have both the Read and Write access.

Hope it helps!

If you have any other issue, please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Thank you very much, Shubham