M002 - Unable to connect to Sandbox cluster from Mongoshell

Hi @Santiago_Alejandro_21418 ,

You are not able to connect to your cluster because your connection string contains blank spaces in-between them. Please make sure you are doing the copy-paste correctly.

If the issue still persists, please get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

hello I did the test without spaces and it gives me this error

\Users\Tibka>mongo “mongodb+srv://sandbox-9qw0d.mongodb.net/test” --username m001-student
MongoDB shell version v3.4.21
connecting to: mongodb://mongodb%2Bsrv:/%2Fsandbox-9qw0d.mongodb.net%2Ftest
2019-07-25T13:39:46.918-0400 E QUERY [thread1] Error: No digits :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed

C:\Users\Tibka>

C:\Users\Tibka>mongo “mongodb://sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017/test?replicaSet=sandbox-shard-0” --ssl --authenticationDatabase admin --username m001-student --password m001-student
MongoDB shell version v3.4.21
connecting to: mongodb://sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017/test?replicaSet=sandbox-shard-0
2019-07-25T13:43:19.389-0400 I NETWORK [thread1] Starting new replica set monitor for sandbox-shard-0/sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017
2019-07-25T13:43:19.687-0400 I NETWORK [thread1] Successfully connected to sandbox-shard-00-00-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-00-9qw0d.mongodb.net:27017 with a 5 second timeout)
2019-07-25T13:43:19.745-0400 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to sandbox-shard-00-02-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-9qw0d.mongodb.net:27017 with a 5 second timeout)
MongoDB server version: 4.0.10
WARNING: shell and server versions do not match
2019-07-25T13:43:20.126-0400 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to sandbox-shard-00-01-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-9qw0d.mongodb.net:27017 with a 5 second timeout)
2019-07-25T13:43:20.348-0400 I NETWORK [thread1] Marking host sandbox-shard-00-00-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-00-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T13:43:20.548-0400 I NETWORK [thread1] Successfully connected to sandbox-shard-00-01-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-9qw0d.mongodb.net:27017 with a 0 second timeout)
2019-07-25T13:43:20.684-0400 I NETWORK [thread1] Marking host sandbox-shard-00-01-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-01-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T13:43:20.910-0400 I NETWORK [thread1] Successfully connected to sandbox-shard-00-02-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-9qw0d.mongodb.net:27017 with a 0 second timeout)
2019-07-25T13:43:21.077-0400 I NETWORK [thread1] Marking host sandbox-shard-00-02-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-02-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T13:43:21.248-0400 I NETWORK [thread1] Marking host sandbox-shard-00-00-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-00-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T13:43:21.249-0400 E QUERY [thread1] Error: can’t authenticate against replica set node sandbox-shard-00-00-9qw0d.mongodb.net:27017: bad auth Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1461:20
@(auth):6:1
@(auth):1:2
exception: login failed

C:\Users\Tibka>7722

Hi @Tibka_Weldeyowhanes_06257,

This error means your credentials could not be authenticated by the server. This generally happens when you are entering wrong combination of username and password.

In the above connection string can you please use m001-mongodb-basics as the --password and see if that resolves the issue.

If the issue still persists, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Microsoft Windows [Version 10.0.17134.915]
© 2018 Microsoft Corporation. All rights reserved.

C:\Users\Tibka>mongo “mongodb://sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017/test?replicaSet=sandbox-shard-0” --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics
MongoDB shell version v3.4.21
connecting to: mongodb://sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017/test?replicaSet=sandbox-shard-0
2019-07-25T15:58:17.410-0400 I NETWORK [thread1] Starting new replica set monitor for sandbox-shard-0/sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017
2019-07-25T15:58:18.063-0400 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to sandbox-shard-00-00-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-00-9qw0d.mongodb.net:27017 with a 5 second timeout)
2019-07-25T15:58:18.063-0400 I NETWORK [thread1] Successfully connected to sandbox-shard-00-01-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-9qw0d.mongodb.net:27017 with a 5 second timeout)
2019-07-25T15:58:18.712-0400 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to sandbox-shard-00-02-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-9qw0d.mongodb.net:27017 with a 5 second timeout)
MongoDB server version: 4.0.10
WARNING: shell and server versions do not match
2019-07-25T15:58:18.933-0400 I NETWORK [thread1] Marking host sandbox-shard-00-00-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-00-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T15:58:19.114-0400 I NETWORK [thread1] Successfully connected to sandbox-shard-00-02-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-9qw0d.mongodb.net:27017 with a 0 second timeout)
2019-07-25T15:58:19.273-0400 I NETWORK [thread1] Marking host sandbox-shard-00-02-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-02-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T15:58:19.471-0400 I NETWORK [thread1] Successfully connected to sandbox-shard-00-01-9qw0d.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-9qw0d.mongodb.net:27017 with a 0 second timeout)
2019-07-25T15:58:19.613-0400 I NETWORK [thread1] Marking host sandbox-shard-00-01-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-01-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T15:58:19.735-0400 I NETWORK [thread1] Marking host sandbox-shard-00-00-9qw0d.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-00-9qw0d.mongodb.net:27017: bad auth Authentication failed.
2019-07-25T15:58:19.736-0400 E QUERY [thread1] Error: can’t authenticate against replica set node sandbox-shard-00-00-9qw0d.mongodb.net:27017: bad auth Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1461:20
@(auth):6:1
@(auth):1:2
exception: login failed

C:\Users\Tibka>mongo “mongodb://sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017/test?replicaSet=sandbox-shard-0” --ssl --authenticationDatabase admin --username m001-student --password mongo “mongodb://sandbox-shard-00-00-9qw0d.mongodb.net:27017,sandbox-shard-00-01-9qw0d.mongodb.net:27017,sandbox-shard-00-02-9qw0d.mongodb.net:27017/test?replicaSet=sandbox-shard-0” --ssl --authenticationDatabase admin --username m001-student --password

i tried but its the same thing i dont know what to do

Hi @Tibka_Weldeyowhanes_06257,

Can you please make sure you have added ALLOW ACCESS FROM ANYWHERE in the Whitelist Entry in your cluster.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

hello I did the test without spaces and it gives me this error

Did you whitelist your IP to connect from anywhere
I am able to connect with this fine

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 Enterprise Cluster0-shard-0:PRIMARY>

Hi @Santiago_Alejandro_21418,

I am able to connect to your cluster using the connection string that you have provided. I believe there is some firewall related issue at your end. Can you please make sure you are able to ping your cluster.

ping cluster0-shard-00-00-jxeqq.mongodb.net

Please share the screenshots of the output.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

I did the test and it gives me this error

test by just typing mongo always succeeds on Windows(your local host)
It connects to default port
The string which connects to class cluster is outside your network
So make sure firewall/anti virus etc not blocking your connection.Also white list your IP as suggested in error message
Are you trying from office or home?
Did you try from another location
Are you able to ping cluster0-shard-00-00-jxeqq.mongodb.net

Dear Sir.
i have same problem unable to connect.

Regards,
Pervaiz

Hi @Santiago_Alejandro_21418,

Please run the command mentioned below in your windows terminal and share the output.

ping cluster0-shard-00-00-jxeqq.mongodb.net

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi pervaizit

Authentication error means issue with your id/password
Make sure no empty spaces/invalid characters while pasting the password

Hi @pervaizit,

As @Ramachandra_37567 mentioned, you are seeing this error message because of the wrong combination fo the Username/Password. Please make sure you are entering the correct password.

If the issue still persists, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi @Santiago_Alejandro_21418,

As I can see in the screenshots, you are entering incorrect connection string. Various parameters are not separated by blank spaces.

Please follow the steps mentioned below. Open your Atlas Cluster.

Click on Connect

After that click on Connect with the Mongo Shell

Then select I have the Mongo Shell installed. Select the 3.6 or later version. Finally click on the Copy button and then go ahead and paste the connection string in your windows terminal.

The terminal will ask for the Password, go ahead and enter the password. After following the above mentioned steps you should be able to connect to your cluster.

If the issue still persists, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer