Connecting to Your Sandbox Cluster from the mongo Shell

C:\Users\anjal>mongo “mongodb+srv://sandbox-pe7hu.mongodb.net/test” --username m001-student --password m001-student-basics
MongoDB shell version v4.2.5
connecting to: mongodb://sandbox-shard-00-00-pe7hu.mongodb.net:27017,sandbox-shard-00-01-pe7hu.mongodb.net:27017,sandbox-shard-00-02-pe7hu.mongodb.net:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Sandbox-shard-0&ssl=true
2020-03-30T01:38:54.810+0530 I NETWORK [js] Starting new replica set monitor for Sandbox-shard-0/sandbox-shard-00-00-pe7hu.mongodb.net:27017,sandbox-shard-00-01-pe7hu.mongodb.net:27017,sandbox-shard-00-02-pe7hu.mongodb.net:27017
2020-03-30T01:38:54.812+0530 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-01-pe7hu.mongodb.net:27017
2020-03-30T01:38:54.814+0530 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-00-pe7hu.mongodb.net:27017
2020-03-30T01:38:54.815+0530 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to sandbox-shard-00-02-pe7hu.mongodb.net:27017
2020-03-30T01:38:55.435+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] Confirmed replica set for Sandbox-shard-0 is Sandbox-shard-0/sandbox-shard-00-00-pe7hu.mongodb.net:27017,sandbox-shard-00-01-pe7hu.mongodb.net:27017,sandbox-shard-00-02-pe7hu.mongodb.net:27017
2020-03-30T01:38:56.029+0530 I NETWORK [js] Marking host sandbox-shard-00-02-pe7hu.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to new replica set master [sandbox-shard-00-02-pe7hu.mongodb.net:27017], err: AuthenticationFailed: bad auth Authentication failed.

*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2020-03-30T01:38:56.034+0530 E QUERY [js] Error: can’t connect to new replica set master [sandbox-shard-00-02-pe7hu.mongodb.net:27017], err: AuthenticationFailed: bad auth Authentication failed. :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-03-30T01:38:56.057+0530 F - [main] exception: connect failed
2020-03-30T01:38:56.059+0530 E - [main] exiting with code 1

this error showing again and again

Two things…

and

… the username/password combination might be wrong

Hi @anjal_49618,

If you don’t remember the correct username and password then you can edit your password by following the steps mentioned below :

  1. Login to your atlas account
  2. Click Database Access.
  3. Click on Edit -> Edit Password.
  4. Enter the new password and then click on Update User.

Once done, then try to connect using the new credentials.

Hope it helps!

Please feel free to get back to us if you have any other query.

Thanks,
Shubham Ranjan
Curriculum Services Engineer