Can't connect to sandbox cluster!

All my trials to connect results in the error statement below
2019-05-16T19:06:09.518-0600 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-05-16T19:06:09.519-0600 E QUERY [js] Error: connect failed to replica set 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 :
connect@src/mongo/shell/mongo.js:343:13
@(connect):2:6
exception: connect failed

I searched but i couldn’t locate any answer from previous discussions.
Kindly help.
Solomon

Are you connecting to Class cluster or Sandbox cluster(your own)?
From your message it appears you are trying to connect to Class cluster
Please paste full command you used or screen shot

Thanks for prompt response. This is the command that I used.

C:\Users\alagb>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

Thanks
Solomon

No issue with the command
Are you using vagrant or Windows for your work?
Are you able to ping the server/host
Please check our forums on troubleshooting connectivity issues

C:\Windows\System32>ping cluster0-shard-00-01-jxeqq.mongodb.net

Pinging ec2-34-205-152-216.compute-1.amazonaws.com [34.205.152.216] with 32 bytes of data:
Reply from 34.205.152.216: bytes=32 time=261ms TTL=36
Reply from 34.205.152.216: bytes=32 time=262ms TTL=36

I am able to connect
C:\Windows\System32>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.5
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-05-17T08:36:32.836+0530 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-05-17T08:36:47.438+0530 I NETWORK [js] Successfully connected to cluster0-shard-00-01-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-01-jxeqq.mongodb.net:27017 with a 5 second timeout)
2019-05-17T08:36:47.447+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] 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-05-17T08:36:48.878+0530 I NETWORK [js] Successfully connected to cluster0-shard-00-02-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-02-jxeqq.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { “id” : UUID(“a4bed503-5343-4547-8f33-650fae5b6deb”) }
MongoDB server version: 3.6.12
WARNING: shell and server versions do not match
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db
test

I am using Windows. I pinged.
C:\WINDOWS\system32>ping cluster0-shard-00-01-jxeqq.mongodb.net

Pinging ec2-34-205-152-216.compute-1.amazonaws.com [34.205.152.216] with 32 bytes of data:
Reply from 34.205.152.216: bytes=32 time=98ms TTL=43
Reply from 34.205.152.216: bytes=32 time=94ms TTL=43
Reply from 34.205.152.216: bytes=32 time=96ms TTL=43
Reply from 34.205.152.216: bytes=32 time=105ms TTL=43

Ping statistics for 34.205.152.216:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 94ms, Maximum = 105ms, Average = 98ms

The command now works.

Many thanks.
Solomon

I am having the same problem! However, the name of my sandbox cluster is Sandbox and the “Copy” option that I have from the atlas copies only this:
mongo "mongodb+srv://sandbox-yom3b.mongodb.net/test" --username m001-student

Then a password pops up but after writing it it displays an error saying it cannot connect.

C:\Users\InesProgramacio>mongo "mongodb+srv://sandbox-yom3b.mongodb.net/test" --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.0.9
connecting to: mongodb://sandbox-shard-00-00-yom3b.mongodb.net.:27017,sandbox-shard-00-01-yom3b.mongodb.net.:27017,sandbox-shard-00-02-yom3b.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Sandbox-shard-0&ssl=true
2019-05-21T17:50:09.307+0200 I NETWORK  [js] Starting new replica set monitor for Sandbox-shard-0/sandbox-shard-00-00-yom3b.mongodb.net.:27017,sandbox-shard-00-01-yom3b.mongodb.net.:27017,sandbox-shard-00-02-yom3b.mongodb.net.:27017
2019-05-21T17:50:09.923+0200 I NETWORK  [js] Successfully connected to sandbox-shard-00-02-yom3b.mongodb.net.:27017 (1 connections now open to sandbox-shard-00-02-yom3b.mongodb.net.:27017 with a 5 second timeout)
2019-05-21T17:50:09.945+0200 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-01-yom3b.mongodb.net.:27017 (1 connections now open to sandbox-shard-00-01-yom3b.mongodb.net.:27017 with a 5 second timeout)
2019-05-21T17:50:10.608+0200 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-00-yom3b.mongodb.net.:27017 (1 connections now open to sandbox-shard-00-00-yom3b.mongodb.net.:27017 with a 5 second timeout)
2019-05-21T17:50:10.631+0200 I NETWORK  [js] Successfully connected to sandbox-shard-00-00-yom3b.mongodb.net:27017 (1 connections now open to sandbox-shard-00-00-yom3b.mongodb.net:27017 with a 5 second timeout)
2019-05-21T17:50:10.733+0200 I NETWORK  [ReplicaSetMonitor-TaskExecutor] changing hosts to Sandbox-shard-0/sandbox-shard-00-00-yom3b.mongodb.net:27017,sandbox-shard-00-01-yom3b.mongodb.net:27017,sandbox-shard-00-02-yom3b.mongodb.net:27017 from Sandbox-shard-0/sandbox-shard-00-00-yom3b.mongodb.net.:27017,sandbox-shard-00-01-yom3b.mongodb.net.:27017,sandbox-shard-00-02-yom3b.mongodb.net.:27017
2019-05-21T17:50:11.302+0200 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-01-yom3b.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-yom3b.mongodb.net:27017 with a 5 second timeout)
2019-05-21T17:50:11.707+0200 I NETWORK  [js] Marking host sandbox-shard-00-00-yom3b.mongodb.net:27017 as failed :: caused by :: Location40659: can't connect to new replica set master [sandbox-shard-00-00-yom3b.mongodb.net:27017], err: Location8000: bad auth Authentication failed.
2019-05-21T17:50:11.947+0200 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-02-yom3b.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-yom3b.mongodb.net:27017 with a 5 second timeout)
2019-05-21T17:50:12.679+0200 I NETWORK  [js] Marking host sandbox-shard-00-01-yom3b.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node sandbox-shard-00-01-yom3b.mongodb.net:27017 :: caused by :: bad auth Authentication failed.
2019-05-21T17:50:13.491+0200 I NETWORK  [js] Marking host sandbox-shard-00-02-yom3b.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node sandbox-shard-00-02-yom3b.mongodb.net:27017 :: caused by :: bad auth Authentication failed.
2019-05-21T17:50:14.408+0200 I NETWORK  [js] Marking host sandbox-shard-00-00-yom3b.mongodb.net:27017 as failed :: caused by :: Location40659: can't connect to new replica set master [sandbox-shard-00-00-yom3b.mongodb.net:27017], err: Location8000: bad auth Authentication failed.
2019-05-21T17:50:14.409+0200 E QUERY    [js] Error: can't authenticate against replica set node sandbox-shard-00-00-yom3b.mongodb.net:27017 :: caused by :: can't connect to new replica set master [sandbox-shard-00-00-yom3b.mongodb.net:27017], err: Location8000: bad auth Authentication failed. :
connect@src/mongo/shell/mongo.js:343:13
@(connect):2:6
exception: connect failed

Please help!

Hi @Ines_55979,

Please add the password option in your Connection string as follows:

mongo “mongodb+srv://sandbox-yom3b.mongodb.net/test” --username m001-student --password <your_password>

Please let me know, if you still face any issue.

Thanks,
Sonali

I tried like that already and get the same error! Do you mean with the <> too? ?
Thank you

Hi @Ines_55979,

No, you just need to put the password.

Please share the connection string with the error you are getting after adding password option in the string.
Also, ensure that you are using the correct password.

Thanks,
Sonali

Solved!! Thank you :))

I add the password string and start the connection but an error message displays.

Please help me.
Thanks.

Ch 2 Lab2.0 Install MongoDB cluster. The registerFromAltas is hung. Won’t let me type and thing/

Hi @Phyo_Wai_48750,

This is just a warning and you can ignore it. You might already be connected to the Atlas cluster.

Please let me know, if you still have any issue.

Thanks,
Sonali

i am using below command but unable to connect

mongo “mongodb+srv://sandbox-wff1x.mongodb.net/test” --username m001-student

Hi @moeed_77345,

Please remove the inverted commas (" ") in the connection string.

You can use this connection string to connect to your sandbox cluster:

mongo mongodb+srv://sandbox-wff1x.mongodb.net/test --username m001-student --password m001-mongodb-basics

Please let me know, if you still face any issue.

Thanks,
Sonali

thank you for swift support
its working fine now.

I’m here to say thanks to topic owner and other guys for really really useful posts. thank you again.

1 Like

I am trying to connect to sandbox cluster from windows shell.
Tried both the version of the connection string as given below, but still getting “connect failed” exception. “Error: Authentication failed.”

mongo “mongodb+srv://sandbox-hygki.mongodb.net/test” --username m001-student --password m001-mongodb-basics

mongo mongodb+srv://sandbox-hygki.mongodb.net/test --username m001-student --password m001-mongodb-basics

Can you please help.

There is no issue with your commands
I am able to connect with and without quotes

I keep getting what looks to be a parsing error. Odd thing is, even though I was previously able to connect to the class’s cluster, I now get the same error.
Here’s the command for my sandbox cluster:
mongo "mongodb+srv://sandbox-7mkrb.mongodb.net/test" --username m001-student --password m001-mongodb-basics
Here’s there error:
2019-05-27T23:37:35.102-0400 E QUERY [thread1] Error: Failed to parse mongodb:// URL: mongodb://mongodb+srv://sandbox-7mkrb.mongodb.net/test : connect@src/mongo/shell/mongo.js:237:clock1130:
Any help is greatly appreciated.