Bad Authentication error while connecting to Atlas Class Cluster

Hi,

Unable to connect from mongo shell to Atlas Class Cluster. Ran into following error. Thoughts on how to fix?

C:\Users\Hema Chavali>mongo “mongodb://sandbox-shard-00-00-g1dmc.mongodb.net:27017,sandbox-shard-00-01-g1dmc.mongodb.net:27017,sandbox-shard-00-02-g1dmc.mongodb.net:27017/test?replicaSet=Sandbox-shard-0” --authenticationDatabase admin --ssl --username hchavali --password m001-mongodb-basics
MongoDB shell version v4.0.3
connecting to: mongodb://sandbox-shard-00-00-g1dmc.mongodb.net:27017,sandbox-shard-00-01-g1dmc.mongodb.net:27017,sandbox-shard-00-02-g1dmc.mongodb.net:27017/test?replicaSet=Sandbox-shard-0
2018-11-08T20:13:28.920-0600 I NETWORK [js] Starting new replica set monitor for Sandbox-shard-0/sandbox-shard-00-00-g1dmc.mongodb.net:27017,sandbox-shard-00-01-g1dmc.mongodb.net:27017,sandbox-shard-00-02-g1dmc.mongodb.net:27017
2018-11-08T20:13:29.289-0600 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-02-g1dmc.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-g1dmc.mongodb.net:27017 with a 5 second timeout)
2018-11-08T20:13:29.361-0600 I NETWORK [js] Successfully connected to sandbox-shard-00-00-g1dmc.mongodb.net:27017 (1 connections now open to sandbox-shard-00-00-g1dmc.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { “id” : UUID(“2f90ac42-1add-4efd-a830-13daf0bc0080”) }
MongoDB server version: 4.0.4
2018-11-08T20:13:30.334-0600 I NETWORK [js] Marking host sandbox-shard-00-00-g1dmc.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-00-g1dmc.mongodb.net:27017 :: caused by :: bad auth Authentication failed.
2018-11-08T20:13:30.520-0600 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-01-g1dmc.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-g1dmc.mongodb.net:27017 with a 5 second timeout)
2018-11-08T20:13:31.124-0600 I NETWORK [js] Successfully connected to sandbox-shard-00-02-g1dmc.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02-g1dmc.mongodb.net:27017 with a 0 second timeout)
2018-11-08T20:13:31.225-0600 I NETWORK [js] Marking host sandbox-shard-00-02-g1dmc.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-02-g1dmc.mongodb.net:27017 :: caused by :: bad auth Authentication failed.
2018-11-08T20:13:31.422-0600 I NETWORK [js] Successfully connected to sandbox-shard-00-01-g1dmc.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01-g1dmc.mongodb.net:27017 with a 0 second timeout)
2018-11-08T20:13:31.534-0600 I NETWORK [js] Marking host sandbox-shard-00-01-g1dmc.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-01-g1dmc.mongodb.net:27017 :: caused by :: bad auth Authentication failed.
2018-11-08T20:13:31.720-0600 I NETWORK [js] Marking host sandbox-shard-00-00-g1dmc.mongodb.net:27017 as failed :: caused by :: Location8000: can’t authenticate against replica set node sandbox-shard-00-00-g1dmc.mongodb.net:27017 :: caused by :: bad auth Authentication failed.
2018-11-08T20:13:31.721-0600 E QUERY [js] Error: can’t authenticate against replica set node sandbox-shard-00-00-g1dmc.mongodb.net:27017 :: caused by :: bad auth Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1685:20
@(auth):6:1
@(auth):1:2
exception: login failed

Is your password actually “m001-mongodb-basics”?!

That’s the password for the student cluster. If you copied that onto your own database, that’s a bit of a security risk :wink: It’s like setting the password to “secret”.

So… If that is NOT your password, you need to adjust the mongo command line. If it IS your password, then you need to first secure your Atlas account a bit better :wink:

Please confirm your username and password.

Note: The user and pass is the cluster [sandbox] credential not you admin atlas cloud credential

I got it to work. Thanks

my password for the atlas i have entered while prompt for password field in the shell it throws error

Hi @Ganesan_02541,

This error message indicates that you are already connected to the mongo shell.

Show me the result of this code:
show dbs

Hi @Ganesan_02541,

In the first screenshot you are getting an error because you already inside the mongo shell. Here you are trying to connect to the class atlas cluster. Please exit out of the mongo shell by running the exit command and then paste and run this command for connecting to the class atlas cluster.

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

In the second screenshot, you are trying to connect to your sandbox cluster. I would request you to share the connection string along with the username and password for your sandbox cluster so that I can test it at my end.

Thanks,
Shubham Ranjan
Curriculum Support Engineer