I set up a cluster on MongoDB Atlas and made myself the admin but I'm having trouble connecting to the Cluster from the shell. On Atlas, I clicked the connect button, clicked connect with Mongo Shell, downloaded the latest Mongo Shell, and copied the command to connect to the cluster:
mongo "mongodb://testcluster-shard-00-00-acqhf.mongodb.net:27017,testcluster-shard-00-01-acqhf.mongodb.net:27017,testcluster-shard-00-02-acqhf.mongodb.net:27017/test?replicaSet=TestCluster-shard-0" --authenticationDatabase admin --ssl --username <USERNAME> --password <PASSWORD>
When I run this command I get the stream:
MongoDB shell version v3.4.10
connecting to: mongodb://testcluster-shard-00-00-
acqhf.mongodb.net:27017,testcluster-shard-00-01-
acqhf.mongodb.net:27017,testcluster-shard-00-02-
acqhf.mongodb.net:27017/test?replicaSet=TestCluster-shard-0
2017-11-20T11:58:31.883-0500 I NETWORK [thread1] Starting new replica set monitor for TestCluster-shard-0/testcluster-shard-00-00-
acqhf.mongodb.net:27017,testcluster-shard-00-01-
acqhf.mongodb.net:27017,testcluster-shard-00-02-acqhf.mongodb.net:27017
2017-11-20T11:58:32.119-0500 I NETWORK [thread1] Successfully connected to testcluster-shard-00-01-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-01-acqhf.mongodb.net:27017 with a 5 second timeout)
2017-11-20T11:58:32.131-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to testcluster-shard-00-00-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-00-acqhf.mongodb.net:27017 with a 5 second timeout)
MongoDB server version: 3.4.10
2017-11-20T11:58:32.407-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to testcluster-shard-00-02-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-02-acqhf.mongodb.net:27017 with a 5 second timeout)
2017-11-20T11:58:32.497-0500 I NETWORK [thread1] Marking host testcluster-shard-00-01-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-01-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:32.639-0500 I NETWORK [thread1] Successfully connected to testcluster-shard-00-02-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-02-acqhf.mongodb.net:27017 with a 0 second timeout)
2017-11-20T11:58:32.756-0500 I NETWORK [thread1] Marking host testcluster-shard-00-02-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-02-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:32.899-0500 I NETWORK [thread1] Successfully connected to testcluster-shard-00-00-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-00-acqhf.mongodb.net:27017 with a 0 second timeout)
2017-11-20T11:58:32.995-0500 I NETWORK [thread1] Marking host testcluster-shard-00-00-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-00-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:33.100-0500 I NETWORK [thread1] Marking host testcluster-shard-00-01-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-01-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:33.101-0500 E QUERY [thread1] Error: can't authenticate against replica set node testcluster-shard-00-01-acqhf.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
I replace the and with my username and password but I still can't connect. Do I need to have mongod running in the background? If not what do I need to do to successfully connect? Thank you.
@ashishkumar148, I would like to say that as per MongoDB BOL Here , MongoDB Atlas cluster only able to connect with MongoDB 3.4 version, due to Mongo Shell with TLS/SSL support. I have gone through you mongo shell log , where i have found out that as you are using MongoDB shell version: 3.2.17.
The Connect dialog for a cluster provides the details to connect to a cluster via the mongo shell. For MongoDB 3.4 clusters, use the 3.4.0 or later version of the mongo shell with TLS / SSL support. For MongoDB 3.6 clusters, use the 3.6.0 or later version of the mongo shell with TLS / SSL support.
Connect to Studio 3T Open Studio 3T and click on Connect in the top-left corner of the toolbar. This will open the Connection Manager. Click on New Connection in the top-left corner, which will open a new connection window. Name your connection and click on the From URI button. Paste the connection string you copied from MongoDB Atlas.
The Connect dialog for a database deployment provides the details to connect to a database deployment via the MongoDB shell, mongosh. Clients must support TLS to connect to an Atlas database deployment. Clients must support the SNI TLS extension to connect to an Atlas M0 free cluster or an M2/M5 shared cluster.
I had to create a new user with a different username and password, and when I ran the command with these new credentials I could connect.
My problem was that I had only recently set / changed the password in the Atlas UI - it takes a minute or so for them to deploy any changes, even password resets etc. I was able to login once I waited for the changes to be deployed
Same as others, did not like my pw. Worked fine from the command line, but not from Compass. Checking the troubleshooting page https://docs.atlas.mongodb.com/troubleshoot-connection/#special-characters-in-connection-string-password. I had special characters in my pw. Tried escaping them, then just went back and reset my password to something simple w/o special characters - took a minute, but then I connected easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With