Unable to connect to database for Lab Connect to Your Atlas Cluster

I use the web IDE and created a database call “sampledb” in the Sandbox cluster.
This is what I typed in the terminal:
mongo “mongodb+srv://sandbox.gdmba.mongodb.net/sampledb” --username m001-student -password m001-mongodb-basics

Following are the error message:
<me m001-student -password m001-mongodb-basics
MongoDB shell version v4.0.5
connecting to: mongodb://sandbox-shard-00-02.gdmba.mongodb.net.:27017,sandbox-shard-00-00.gdmba.mongodb.net.:27017,sandbox-shard-00-01.gdmba.mongodb.net.:27017/sample_training?authSource=admin&gssapiServiceName=mongodb&replicaSet=atlas-sn90qq-shard-0&ssl=true
2020-10-03T01:24:57.969+0000 I NETWORK [js] Starting new replica set monitor for atlas-sn90qq-shard-0/sandbox-shard-00-02.gdmba.mongodb.net.:27017,sandbox-shard-00-00.gdmba.mongodb.net.:27017,sandbox-shard-00-01.gdmba.mongodb.net.:27017
2020-10-03T01:24:58.112+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:24:58.112+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2020-10-03T01:24:58.652+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:24:58.652+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2020-10-03T01:24:59.192+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:24:59.192+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2020-10-03T01:24:59.732+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:24:59.732+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 4 checks in a row.
2020-10-03T01:25:00.278+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:00.278+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 5 checks in a row.
2020-10-03T01:25:00.818+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:00.819+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 6 checks in a row.
2020-10-03T01:25:01.359+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:01.359+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 7 checks in a row.
2020-10-03T01:25:01.901+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:01.901+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 8 checks in a row.
2020-10-03T01:25:02.441+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:02.441+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 9 checks in a row.
2020-10-03T01:25:02.981+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:02.981+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 10 checks in a row.
2020-10-03T01:25:03.521+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:03.521+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 11 checks in a row.
2020-10-03T01:25:04.061+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:04.604+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:05.145+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:05.684+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:06.224+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:06.766+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:07.306+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:07.846+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:08.386+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:08.926+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:08.926+0000 I NETWORK [js] Cannot reach any nodes for set atlas-sn90qq-shard-0. Please check network connectivity and the status of the set. This has happened for 21 checks in a row.
2020-10-03T01:25:09.471+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:10.011+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:10.551+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:11.091+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:11.632+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:12.172+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:12.712+0000 W NETWORK [js] Unable to reach primary for set atlas-sn90qq-shard-0
2020-10-03T01:25:12.712+0000 E QUERY [js] Error: connect failed to replica set atlas-sn90qq-shard-0/sandbox-shard-00-02.gdmba.mongodb.net.:27017,sandbox-shard-00-00.gdmba.mongodb.net.:27017,sandbox-shard-00-01.gdmba.mongodb.net.:27017 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

Hi @Fan_Chen,

Did you create network access to your cluster? There is a step in the instructions that asks you to hit “Allow access from anywhere” in the network access section of your Atlas Cluster.

Additionally it looks like you’re missing a - before password. It is supposed to be --password instead of -password.

Thanks Yulia, the password parameter is actually a typo when I did above but not in my web terminal. The “Allow access from anywhere actually” solved my issue, I was using my own ip in the previous exercise.
Not sure why that is the issue, unless the terminal is not an actually online IDE that hosted in the cloud server, but uses our local brower as a client to connect to the database similar to the MongoDB compass? And because my ip is dynamics it throws the error when I only enable my connection by whitelist my ip address?

This is not necessarily the IP address that the cluster is seeing. If your Internet provider, uses NAT on your router, it is the address of the router. If you are using a VPN is the public address at the exit point of the VPN. The following will give you your real public IP

https://www.whatismyip.com/