Can't connect the Mongodb Atlas With MongoDb Shell

When I connect to the Mongodb Atlas with the MongoDB Shell, I can’t connect to the MongoDB Atlas even though I type the user name and the password. Please someone guide me to the why the connection is failed?mongodb%20shell

Hi @San_54816,

Did you try the steps mentioned in the following post?

If you are facing any trouble in the above post, please let me know.

Thanks,
Sonali

1 Like

Even though I done the ways that you show me, the same error is occurred. The solution that you point me can’t resolve the error. Can you able to show me the another ways of solving the error.

Hi @San_54816,

Can you please try to connect using the following connection string:

mongo mongodb+srv://cluster0-6ngw3.mongodb.net/test --username m001-student --password m001-mongodb-basics

I am able to connect to the cluster using the above Connection String. Please refer to the screenshot below:

Please make sure if you have connected vpn on your device or you are in office network, then also connection to cluster gets blocked. If that is an issue, try using home/personal network in that case.

Let me know, if you are able to connect now.

Thanks,
Sonali

1 Like

I done the ways you told me to get the connection between the mongodb shell and the mongodb atlas. But nothing happen. But I get the connection to the Mongodb Compass with the MongoDB Atlas.

Hi @San_54816,

As i can see you have successfully connected to the Sandbox cluster using Compass.
That is great!!

Are you facing issues while connecting to the cluster in mongo shell using the above connection string also?

Thanks,
Sonali

The same issue is being faced by me. I can connect through the MongoDB Compass with the MongoDB Atlas but unable to connect between mongodb shell and atlassssss

I am able to connect with your command from shell
May be temporary connectivity issues?
or some firewall preventing your connection
Try to whitelist your ip

C:\Users\ramrt\M001\loadMovieDetailsDataset>mongo mongodb+srv://cluster0-nuozd.mongodb.net/test --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.0.5
connecting to: mongodb://cluster0-shard-00-00-nuozd.mongodb.net.:27017,cluster0-shard-00-01-nuozd.mongodb.net.:27017,cluster0-shard-00-02-nuozd.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db
test

1 Like

Yes that was a temporary connectivity issue it is now working without any problems

I’m having similar issues. I have no problem logging in to my sandbox cluster via compass, but I can’t do the same thing via the mongo shell. I have also double-checked to make sure that my ip was whitelisted, and it was. This is driving me nuts.

Hi @Brandon_48087,

Please share the screenshot of the connection string to connect with sandbox cluster and the error message that you are getting.

Thanks,
Sonali

Here are my screens:

Hi @Brandon_48087,

You are already connected to the Atlas Sandbox cluster. You are getting this error because you are running connection string from within the Mongo Shell.

You can just run the following command to check that you are connected to the cluster:

show dbs

Please let me know, if you have any questions.

Thanks,
Sonali

When I list the databases, I can see locally created databases only, but I can’t see my sandbox cluster, nor can I see the M001 class database. Thanks for your reply.

Hi @Brandon_48087,

After you are connected to the Sandbox Cluster, you need to load the data into your cluster. Please refer to the Lecture: Loading Data into your Sandbox Cluster.

To view M001 class cluster databases, you need to connect to the Class Atlas Cluster as mentioned in the Lecture: Connecting to Our Class Atlas Cluster from the Mongo Shell.

Please let me know, if you have any questions.

Thanks,
Sonali

I too am having problesm connecting MongoDb Shell

C:\Program Files\MongoDB\Server\4.0\bin>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
MongoDB shell version v4.0.10
connecting to: 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?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0
2019-07-05T14:32:05.859+0100 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017
2019-07-05T14:32:06.128+0100 E NETWORK [ReplicaSetMonitor-TaskExecutor] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:06.128+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:06.141+0100 E NETWORK [ReplicaSetMonitor-TaskExecutor] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:06.141+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:06.860+0100 I NETWORK [js] Successfully connected to cluster0-shard-00-00-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-jxeqq.mongodb.net:27017 with a 5 second timeout)
2019-07-05T14:32:06.951+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:07.613+0100 I NETWORK [js] Successfully connected to cluster0-shard-00-00-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-jxeqq.mongodb.net:27017 with a 0 second timeout)
2019-07-05T14:32:08.189+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:08.190+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:08.412+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:08.413+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:08.414+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:09.216+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:09.217+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:09.406+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:09.406+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:09.408+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:10.234+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:10.234+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:10.445+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:10.446+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:10.450+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:11.284+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:11.284+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:11.482+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:11.483+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:11.488+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:12.307+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:12.307+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:12.508+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:12.509+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:12.510+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:13.317+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:13.318+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:13.532+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:13.533+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:13.534+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:14.354+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:14.355+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:14.578+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:14.578+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:14.580+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:15.408+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:15.408+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:15.620+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:15.621+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:15.623+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:16.430+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:16.431+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:16.643+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:16.643+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:16.645+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:17.434+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:17.435+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:17.665+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:17.666+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:17.668+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:18.472+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:18.473+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:18.685+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:18.686+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:18.691+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:19.507+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:19.507+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:19.723+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:19.723+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:19.727+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:20.543+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:20.543+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:20.770+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:20.771+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:20.774+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:21.581+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:21.582+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:21.809+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:21.810+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:21.817+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-07-05T14:32:22.621+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:22.621+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:22.831+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:22.832+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T14:32:22.837+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0

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

2019-07-05T14:32:22.842+0100 E QUERY [js] Error: Could not find host matching read preference { mode: “primary”, tags: [ {} ] } for set Cluster0-shard-0 :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

C:\Program Files\MongoDB\Server\4.0\bin>

Hi @Phill_40649,

Please follow the instructions mentioned in the following posts to resolve this error:

Please let me know, if you have any questions.

Thanks,
Sonali

Tried using

mongo --ssl --host 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/?replicaSet=Cluster0-shard-0 --authenticationDatabase admin --username m001-student --password m001-mongodb-basics

As described and get the same error

a long list of repeated errors finaly terminating with

2019-07-05T15:13:11.376+0100 E NETWORK [js] SSL peer certificate validation failed: (800B0109)A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
2019-07-05T15:13:11.378+0100 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0

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

2019-07-05T15:13:11.384+0100 E QUERY [js] Error: Could not find host matching read preference { mode: “primary”, tags: [ {} ] } for set Cluster0-shard-0 :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

How do make this check

Please ensure that your IP whitelist allows connections from your network.

…Login to your atlas account and check network…

What account is that ?

Hi @Sonali_Mamgain,

i am also facing the connection issue from the instructions. i wanted to know the difference between the
following commands

Command 1: mongo mongodb+srv://cluster0-6ngw3.mongodb.net/test --username m001-student --password m001-mongodb-basics
Which is working fine from Mongo Shell and when i did show db unable to get the existing databases from the clusters but able to switch the databases with in the clusters

Command 2: mongo “mongodb+srv://snadbox.pjr8r.mongodb.net/sample_airbnb” --username m001-student --password m001-mongodb-basics
Error : 2021-03-10T14:32:34.717+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor] Cannot reach any nodes for set atlas-103xnl-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.

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

2021-03-10T14:32:34.725+0000 E QUERY [js] Error: connect failed to replica set atlas-103xnl-shard-0/snadbox-shard-00-02.pjr8r.mongodb.net:27017,snadbox-shard-00-00.pjr8r.mongodb.net:27017,snadbox-shard-00-01.pjr8r.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2021-03-10T14:32:34.742+0000 F - [main] exception: connect failed
2021-03-10T14:32:34.747+0000 E - [main] exiting with code 1

Thanks in Advance
Shareef