Error connecting to sandbox cluster

Screenshot (7) Screenshot (8)

An error occurred while loading navigation: ‘not master and slaveOk=false’: It is recommended to change your read preference in the connection dialog to Primary Preferred or Secondary Preferred or provide a replica set name for a full topology connection.

I got the above error in compass inspite of the fact that the entered connection string has preference primary. How to fix this?

What connection string?

the one entered in 2nd image
just above the connect button

Need to see the full connection string. Better still, paste it here.

mongodb://m001-student:m001-mongodb-basics@cluster0-shard-00-01-kduqb.mongodb.net:27017/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=true

You need to copy the string directly from Atlas and you’ll get something similar to this:
mongodb://m001-student:m001-mongodb-basics@cluster0-shard-00-00-kduqb.mongodb.net:27017,cluster0-shard-00-01-kduqb.mongodb.net:27017,cluster0-shard-00-02-kduqb.mongodb.net:27017/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=true

Basically, you needed to supply all the nodes within the connection string in order for it to find the PRIMARY node. 00-01 is a Secondary node hence the error.

Hi @Hetal_57847,

As @007_jb mentioned, please login to your atlas account for getting the connection string. Please refer this post for further instructions.

For your sandbox cluster, please use this connection string :

mongodb+srv://m001-student:m001-mongodb-basics@cluster0-kduqb.mongodb.net/test

Hope it helps!

Please let us know if you have any other questions.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

I tried using this connection string to connect to atlas cluster via shell.


I am getting the following error

For testing purposes, Whitelist all IP addresses to your cluster and share the connection string so that I can test it on my end.

mongo “mongodb+srv://cluster0-kduqb.mongodb.net/test” --username m001-student --password m001-mongodb-basics

As you can see, I can connect:

Try this:
mongo "mongodb://m001-student:m001-mongodb-basics@cluster0-shard-00-00-kduqb.mongodb.net:27017,cluster0-shard-00-01-kduqb.mongodb.net:27017,cluster0-shard-00-02-kduqb.mongodb.net:27017/?authSource=admin&readPreference=primary&ssl=true"

it got connected to secondary. I don’t get it what went wrong at my end?

Can you elaborate? Or share a screenshot.

I mean why wasn’t I able to connect with the string I had mentioned before


also I am not able to list the databases

My mistake, use this:
mongo "mongodb://m001-student:m001-mongodb-basics@cluster0-shard-00-00-kduqb.mongodb.net:27017,cluster0-shard-00-01-kduqb.mongodb.net:27017,cluster0-shard-00-02-kduqb.mongodb.net:27017/admin?replicaSet=Cluster0-shard-0&authSource=admin&readPreference=primary&ssl=true"

Also what country are you located? And what region did you choose for your Atlas?

I have selected AWS / N. Virginia (us-east-1) as my region. I am from India. This was default region so I didn’t change it.

Thanks for this. I was trying so hard and this worked out. :slight_smile:

So it looks like you can connect using the Seed List connection string (i.e. the long format) but it doesn’t work with the SRV connection string (short version, “mongodb+srv”). I’ve only seen this same thing happen to another user located in Pakistan and someone else in the Middle East.

Can you confirm if you’re using a VPN or a work laptop?

Neither. This is my personal laptop.