M002 - Unable to connect to Sandbox cluster from Mongoshell

Hi,

I am trying to connect to the Sandbox cluster from the Mongo shell but I keep hitting the following error.

C:\Users\kiran>mongo “mongodb+srv://sandbox-rnm7l.mongodb.net/test” --username m001-student
MongoDB shell version v3.4.14
connecting to: mongodb://mongodb%2Bsrv:/%2Fsandbox-rnm7l.mongodb.net%2Ftest
2019-07-22T21:08:34.297-0400 E QUERY [thread1] Error: No digits :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed

I have used the following command to connect and I have created Sandbox cluster(please refer to the screenshot below).image

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

I am able to connect with your string
Did you give password when it prompted
Make sure no spaces/invalid characters while cut & pasting commands/password

Your current MongoDB shell version is 3.4. But your connection string is for 3.6 or later. I’ll suggest you to check the step1 “Select your Mongo Shell version”, and select the correct version

1 Like

Hi @Kiran_Nelapudi_59534,

As mentioned by @ziqi_32189, you are using MongoDB shell version v3.4.14 in your system but you are using the connection string which is for MongoDB shell version 3.6 or later.

Please follow the steps mentioned below to get the correct connection string for your shell version.

In your sandbox cluster, select the 3.4 or earlier option from the dropdown and then copy the string at the bottom to connect to your sandbox cluster.

If you still have any query, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi! I have the same problem I can’t connect to the sandbox cluster from the shell using the recommended line command: mongo “mongodb+srv://sandbox-zyvd3.mongodb.net/test” --username m001-student

What error you are getting?
I am able to connect with your string
Please follow above steps about version of shell vs version of string

Hi!
I am receiving the following message:
2019-07-24T10:58:09.455+0200 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6

And the line command that I am using is:
mongo “mongodb+srv://sandbox-zyvd3.mongodb.net/test” --username m001-student

I can connect with that command as long as the quotes are changed from that fancy font.

What version on the shell are you using?

mongo --version

Hi!
The version is: v4.0.10

Hi @Marcos_33957,

This error means that you are already connected to some mongod instance and you are inside the mongo shell.

To verify this you can exit out of the mongo shell by using the quit command and then use your connection string to connect to your sandbox cluster.

quit()

If you still have any issue, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Thank!.. That was the problem… I was starting the mongo shell and I were direct connected to the preview DB M001 RS. I should start direct from the command line window cmd.

Thank you Shubham! After I selecting the correct MongoDB shell version I get the following error.
MongoDB shell version v3.4.14
connecting to: mongodb://sandbox-shard-00-00-rnm7l.mongodb.net:27017,sandbox-shard-00-01-rnm7l.mongodb.net:27017,sandbox-shard-00-02-rnm7l.mongodb.net:27017/test?replicaS
et=Sandbox-shard-0
2019-07-24T09:33:37.656-0400 I NETWORK [thread1] Starting new replica set monitor for Sandbox-shard-0/sandbox-shard-00-00-rnm7l.mongodb.net:27017,sandbox-shard-00-01-rnm
7l.mongodb.net:27017,sandbox-shard-00-02-rnm7l.mongodb.net:27017
2019-07-24T09:33:42.802-0400 W NETWORK [thread1] Failed to connect to 18.207.48.183:27017 after 5000ms milliseconds, giving up.
2019-07-24T09:33:42.899-0400 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 3.222.121.183:27017 after 5000ms milliseconds, giving up.
2019-07-24T09:33:47.975-0400 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 3.222.198.42:27017 after 5000ms milliseconds, giving up.
2019-07-24T09:33:47.976-0400 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] No primary detected for set Sandbox-shard-0
2019-07-24T09:33:47.982-0400 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] All nodes for set Sandbox-shard-0 are down. This has happened for 1 checks in a row.
2019-07-24T09:33:53.491-0400 W NETWORK [thread1] Failed to connect to 18.207.48.183:27017 after 5000ms milliseconds, giving up.
2019-07-24T09:33:58.493-0400 W NETWORK [thread1] Failed to connect to 3.222.198.42:27017 after 5000ms milliseconds, giving up.
2019-07-24T09:34:03.494-0400 W NETWORK [thread1] Failed to connect to 3.222.121.183:27017 after 5000ms milliseconds, giving up.
2019-07-24T09:34:03.495-0400 W NETWORK [thread1] No primary detected for set Sandbox-shard-0
2019-07-24T09:34:03.499-0400 I NETWORK [thread1] All nodes for set Sandbox-shard-0 are down. This has happened for 2 checks in a row.
2019-07-24T09:34:03.616-0400 E QUERY [thread1] Error: connect failed to replica set Sandbox-shard-0/sandbox-shard-00-00-rnm7l.mongodb.net:27017,sandbox-shard-00-01-rnm
7l.mongodb.net:27017,sandbox-shard-00-02-rnm7l.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed

Hi @Kiran_Nelapudi_59534,

Can you please make sure you are able to ping your cluster by executing the below mentioned command in your terminal.

ping sandbox-shard-00-00-rnm7l.mongodb.net

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi Shubham,

The requests are timing out when I try to ping for the cluster

Pinging ec2-18-207-48-183.compute-1.amazonaws.com [18.207.48.183] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 18.207.48.183:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

Thanks,
Kiran NR

Hi Shubham,

I was able to connect to the cluster. The issue was with my wifi network.

Thanks,
Kiran NR

Hi @Kiran_Nelapudi_59534,

Great work. If you still have any issue feel free to get back to us :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi ,I have the same problem,I am trying to connect to sandbox cluster the mongo shell but excecption failed

Hi @Tibka_Weldeyowhanes_06257,

Can you please share the screenshots of the error that you are getting and also share your connection string that you are using to connect to your cluster.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hola no me puedo conectar con mongo shell

Do not but spaces between after the commas. Better yet is to put the URL is quotes.

Lo siento, no habla español.