Connection Failed : Not able to connect to mongo shell

Hi,

I am trying to connect to mongodb shell by using below command
mongo “mongodb://cluster0-shard-00-00-zyvmb.mongodb.net:27017,cluster0-shard-00-01-zyvmb.mongodb.net:27017,cluster0-shard-00-02-zyvmb.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --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/cluster0-shard-00-00-zyvmb.mongodb.net:27017,cluster0-shard-00-01-zyvmb.mongodb.net:27017,cluster0-shard-00-02-zyvmb.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed

Please Suggest.

Regards,
Rohit

Issue is closed now.

Regards,
Rohit

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?

Yes!!.
I added my system IP(which is auto deducted public ip) , also 0.0.0.0 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.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi @Shubham_Ranjan,

mongo “cluster0-shard-00-00-ivkuj.mongodb.net:27017,cluster0-shard-00-01-ivkuj.mongodb.net:27017,cluster0-shard-00-02-ivkuj.mongodb.net:27017/test?replicaSet=cluster0-shard-0” --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. 0.0.0.0) 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.

image

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 "cluster0-shard-00-00-ivkuj.mongodb.net:27017,cluster0-shard-00-01-ivkuj.mongodb.net:27017,cluster0-shard-00-02-ivkuj.mongodb.net:27017/test" --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://cluster0-ivkuj.mongodb.net/test" -u admin -p m001-admin

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

Thanks,
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.

Reason:
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.

Thanks,
Shubham Ranjan
Curriculum Support Engineer