Connection Failed : Not able to connect to mongo shell


I am trying to connect to mongodb shell by using below command
mongo “mongodb://,,” --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics

But in return I am getting the below error.I have added my system IP whitelist in security tab and status is Active.

2019-01-13T21:27:09.499+0530 E QUERY [js] Error: connect failed to replica set Cluster0-shard-0/,, :
exception: connect failed

Please Suggest.


Issue is closed now.


So, whats the solution mate?? I’m getting the same error!!

Hi @RajaPraveenRatan_89384, have you done this? :arrow_up:
What is your connection string?

I added my system IP(which is auto deducted public ip) , also as mentioned.
Will check few more settings and try and post if i’m still stuck.

Does your connection string include a password? And does it have the word “SRV”?

Hi @RajaPraveenRatan_89384,

If you are still facing the same issue then please share your connection string and the password so that I can test if from my end.

In addition to this, please make sure that you are able to ping and telnet your cluster.

Shubham Ranjan
Curriculum Support Engineer

Hi @Shubham_Ranjan,

mongo “,,” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

I’m not able to connect to your private cluster either. If you say that you allowed everyone (i.e. then I suspect that the username/password is wrong. Can you create a simple read-only user with username=admin and password=password for testing? You can delete it soon.


username = admin
password = m001-admin

Can you please try now

Ok, I’m able to connect. You were using the wrong replica set name in your connection string. Use this:

mongo ",," --authenticationDatabase admin --ssl --username admin --password m001-admin

I think what you did was edit the connection string from the Class Cluster which meant that you missed the replica set part. For next time, you can get the connection string from here (follow the prompts):

Hi @RajaPraveenRatan_89384,

I’m just curious to know from where did you get this connection string ?

mongo "mongodb+srv://" -u admin -p m001-admin

Alternatively, you can also try to connect using this connection string.

Shubham Ranjan
Curriculum Support Engineer

@Shubham_Ranjan hubham_Ranjan,

  1. Actual Conn string — I did it manually by looking into the names of cluster replica set.
  2. The other “admin” string ---- I did not use it to connect. It was in request of @007_jb, I created a sample user with a password.

When I tried to do it the way it is supposed to, I’m not able to get the complete connection string with my cluster nodes for some reason.

Btw, I selected the dropdown option ( 3.4 or before for Mongo shell).

Hi @RajaPraveenRatan_89384,

Thanks for providing the information. Let me know if you are still facing any issue.

Shubham Ranjan
Curriculum Support Engineer