Cannot connect in chapter 1 ide

Followed all instructions verbatim except using own IP which is static. When I copy/paste and edit the string and enter the password I just get:

bash-4.4# mongo "mongodb+srv://sandbox.ookdy.mongodb.net/sandbox" --username m001-student
MongoDB shell version v4.0.5
Enter password: 
connecting to: mongodb://sandbox-shard-00-02.ookdy.mongodb.net.:27017,sandbox-shard-00-00.ookdy.mongodb.net.:27017,sandbox-shard-00-01.ookdy.mongodb.net.:27017/sandbox?authSource=admin&gssapiServiceName=mongodb&replicaSet=atlas-y7n2pd-shard-0&ssl=true
2020-11-02T22:52:46.672+0000 I NETWORK  [js] Starting new replica set monitor for atlas-y7n2pd-shard-0/sandbox-shard-00-02.ookdy.mongodb.net.:27017,sandbox-shard-00-00.ookdy.mongodb.net.:27017,sandbox-shard-00-01.ookdy.mongodb.net.:27017
2020-11-02T22:52:47.904+0000 W NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:52:47.904+0000 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2020-11-02T22:52:50.211+0000 W NETWORK  [js] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:52:50.211+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2020-11-02T22:52:52.522+0000 W NETWORK  [js] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:52:52.522+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2020-11-02T22:52:54.828+0000 W NETWORK  [js] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:52:54.828+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 4 checks in a row.
2020-11-02T22:52:57.142+0000 W NETWORK  [js] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:52:57.142+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 5 checks in a row.
2020-11-02T22:52:59.451+0000 W NETWORK  [js] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:52:59.451+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 6 checks in a row.
2020-11-02T22:53:01.757+0000 W NETWORK  [js] Unable to reach primary for set atlas-y7n2pd-shard-0
2020-11-02T22:53:01.757+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-y7n2pd-shard-0. Please check network connectivity and the status of the set. This has happened for 7 checks in a row.
2020-11-02T22:53:01.757+0000 E QUERY    [js] Error: connect failed to replica set atlas-y7n2pd-shard-0/sandbox-shard-00-02.ookdy.mongodb.net.:27017,sandbox-shard-00-00.ookdy.mongodb.net.:27017,sandbox-shard-00-01.ookdy.mongodb.net.:27017 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

I’ve tried adding a different user/password but the same thing happens.

Adding to my problem, I installed mongodb locally and attempted to connect from a bash shell there. Now I get:
(paul_dev) ~/wk/cliosoft/related_projects/mongodb $ mongo “mongodb+srv://sandbox.ookdy.mongodb.net/Sandbox” --username paul
MongoDB shell version v4.4.1
Enter password:
connecting to: mongodb://sandbox-shard-00-02.ookdy.mongodb.net:27017,sandbox-shard-00-01.ookdy.mongodb.net:27017,sandbox-shard-00-00.ookdy.mongodb.net:27017/Sandbox?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-y7n2pd-shard-0&ssl=true
{“t”:{"$date":“2020-11-02T23:41:01.676Z”},“s”:“E”, “c”:“NETWORK”, “id”:23256, “ctx”:“ReplicaSetMonitor-TaskExecutor”,“msg”:“SSL peer certificate validation failed”,“attr”:{“error”:“SSL peer certificate validation failed: unable to get local issuer certificate”}}

The validation failure fails repeatedly.

It appears that ssl is True by default and that was not set up in the tutorial.

I can’t see a way to turn ssl off using the mongo command (I could turn it on with --tls but it is already on).

Using the database names makes no difference.

May be DNS issue or your network not supporting SRV type string
Please check this link and try different connect strings like long form,with TLS etc
Also check how to use google DNS

SSL peer certificate validation failed: unable to get local issuer certificate

@Paul_Whipp The in-browser IDE doesn’t have the same IP as your local static IP, it uses a remote VM, so if you want to connect through the IDE you need to allow access from anywhere in the network settings to your cluster. For the local install and connection, it could be what Ramachandra_37567 is suggesting.

1 Like

Doh, thanks yulia, that makes perfect sense. Sorry I didn’t think of it.
Works in the IDE now.

I’ve switched the DNS to google and the issue changes to:
~ $ mongo “mongodb+srv://sandbox.ookdy.mongodb.net/sample_airbnb” --username paul
MongoDB shell version v4.4.1
Enter password:
connecting to: mongodb://sandbox-shard-00-02.ookdy.mongodb.net:27017,sandbox-shard-00-01.ookdy.mongodb.net:27017,sandbox-shard-00-00.ookdy.mongodb.net:27017/sample_airbnb?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-y7n2pd-shard-0&ssl=true
Implicit session: session { “id” : UUID(“f009f02a-7cdf-4019-9f6d-c5e42eaada4e”) }
MongoDB server version: 4.2.10
WARNING: shell and server versions do not match

All good now, thanks.