Unable to connect to mongodb cluster from shell

Mongo Shell version 4.2.1

DB user Access level : Atlas admin

on the ATLAS : Network access >> IP whitelist >> (includes your current IP address) status active

**shell cmd : **
mongo “mongodb+srv://cluster0-ye4gj.azure.mongodb.net/admin” --username xxxx --password xxxx


2019-11-16T22:49:36.975-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor] Cannot reach any nodes for set Cluster0-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.

2019-11-16T22:49:37.019-0500 E QUERY [js] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-02-ye4gj.azure.mongodb.net:27017,cluster0-shard-00-00-ye4gj.azure.mongodb.net:27017,cluster0-shard-00-01-ye4gj.azure.mongodb.net:27017 :
2019-11-16T22:49:37.049-0500 F - [main] exception: connect failed
2019-11-16T22:49:37.049-0500 E - [main] exiting with code 1

shell cmd : mongo “mongodb+srv://cluster0-shard-00-00-ye4gj.azure.mongodb.net:27017/admin” --username xxxx --password xxxx

Error: DNSHostNotFound : Failed to look up service

here is the ping status :


May be firewall preventing the connection
Please try long form of connect string instead of srv string as suggested in this link

DNSHostNotFound error when connecting with Mongo Shell

That did not get me connected, I used the connection string that was within the thread

CS: mongo mongodb://sandbox-shard-00-00-qhfg0.mongodb.net:27017,sandbox-shard-00-01-qhfg0.mongodb.net.mongodb.net:27017,sandbox-shard-00-02-qhfg0.mongodb.net:27017/test?replicaSet=Sandbox-shard-0 --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics

I also sub the cluster with my cluster created for class, that did not get connected either
CS: mongo mongodb://cluster0-shard-00-00-ye4gj.azure.mongodb.net:27017,cluster0-shard-00-01-ye4gj.azure.mongodb.net:27017,cluster0-shard-00-02-ye4gj.azure.mongodb.net:27017/video?replicaSet=cluster0-shard-0 --ssl --authenticationDatabase admin --username xxxx --password xxxx

Error Result:

Also, Can you please verify that my cluster is for the class with zero bill - no billing


I can connect with the first CS.Did you try with TLS as suggested in the error from your snapshot?

For second CS i am getting network error
[js] Error: network error while attempting to run command ‘isMaster’ on host ‘cluster0-shard-00-02-ye4gj.azure.mongodb.net:27017

Is your cluster up and running?What does status show in Atlas
You have to choose free tier cluster
Course instructors can verify what type you have choosen

Heres the cluster status image

I still cannot connect ,

Hi @mdb_user,

Are you trying to connect from your office network/ connected to any VPN network ?

Please make sure firewall/anti-virus is not blocking the connection requests. In addition to this, I will request you to share the username and password for your cluster so that I can test it at my end.

Shubham Ranjan
Curriculum Support Engineer

Its my home PC, firewall has access for MongoShell image

IP is whitelisted:

UID: patel01 PWD: patel01


Hi @mdb_user,

In the Network Access setting please select Allow Access From Anywhere so that I can attempt to connect from my end.

Shubham Ranjan
Curriculum Support Engineer

Settings as suggested: image


Please try this.It is working for me

mongo “mongodb+srv://cluster0-ye4gj.azure.mongodb.net/admin” --username patel01 --password patel01
MongoDB shell version v4.0.5
connecting to: mongodb://cluster0-shard-00-00-ye4gj.azure.mongodb.net.:27017,cluster0-shard-00-01-ye4gj.azure.mongodb.net.:27017,cluster0-shard-00-02-ye4gj.azure.mongodb.net.:27017/admin?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
Implicit session: session { “id” : UUID(“f1f80cc9-3b03-4287-9c7c-e79eb90604e7”) }
MongoDB server version: 4.0.13
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

or this string without replicasetname

mongo mongodb://cluster0-shard-00-00-ye4gj.azure.mongodb.net:27017,cluster0-shard-00-01-ye4gj.azure.mongodb.net:27017,cluster0-shard-00-02-ye4gj.azure.mongodb.net:27017/test? --ssl --authenticationDatabase admin --username patel01 --password patel01

the second CS worked with SSL deprecated warning, if I remove --ssl it gives error, Thanks

Hi @mdb_user,

I’m glad your issue got resolved. If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Shubham Ranjan
Curriculum Support Engineer