Not able to connect to MongoDB Atlas using Mongo Shell or MongoDB Compass

Hi Team,

Am unable to connect to atlas cluster through mongo shell or compass from my local machine.

Steps i did

  1. Add my current machine IP in ‘IP Access list’ settings in ‘Atlas Network Access’.

  2. Connect through mongo shell :
    mongo “mongodb+srv://” --username kunal

  3. Entered password

  4. Error ‘You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.’

  5. Turned off my firewall in my local machine.

  6. Tried again , but failed to connect with same error message as above.

No idea why the connection is getting refused again and again . Can someone point where i am doing wrong.

Hi Kunal,

Error: Authentication failed

The above error generally indicates credentials were entered incorrectly. You can try changing the password for user kunal in the Database Access section of the Atlas UI or create another temporary test user to verify that the credentials are being entered correctly.

You may find the following Atlas documentation for this useful as well:

Hope this helps.

Kind Regards,

1 Like

Hi Jason,

I already tried changing my username and password many times but no luck.

I have created one new account (different email id) in Atlas and configured cluster but while connecting through mongo shell i am facing same issue with my new account too

mongo mongodb+srv://

MongoDB shell version v4.4.5

connecting to: mongodb://,,

Implicit session: session { “id” : UUID(“9ffaa6dc-31d2-4af7-8bcf-9c96fb387ea7”) }
MongoDB server version: 4.4.6

Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]

MongoDB Enterprise atlas-11qgt0-shard-0:SECONDARY> db.auth(“m1003-admin” , “m1003-pass”)
Error: Authentication failed.

Wonder why ‘secondary server’ is picked up when connecting as below

mongo mongodb+srv:// -u m1003-admin -p m1003-pass
MongoDB shell version v4.4.5
connecting to: mongodb://,,
Implicit session: session { “id” : UUID(“d8ca331c-e0e4-41a7-8608-b17c7c0aac53”) }
MongoDB server version: 4.4.6
MongoDB Enterprise atlas-11qgt0-shard-0:SECONDARY>

Hi Jason,

Thanks for reply. I have replied to your comment earlier, this one is just to add information that i created new account, new database user but all are failing with same error message

Seems, there are some other issues which i am not able to figure out.

I have attached screenshots of my atlas configuration - Network Access, Database Access , Error Message

Hi @Kunal_Kumar,

Thanks for getting back to me with that information and confirming you’ve tried different combination of credentials.

Wonder why ‘secondary server’ is picked up when connecting as below

Based off your screenshots, I can see the connection attempts are being made to 3 hosts with a few other options such as ssl=true . However, I cannot see the replicaSet value. For troubleshooting purposes, would you be able to try connecting using the standard connection string format? To get this, please follow the below steps:

  1. Head over to your Clusters section in the Atlas UI
  2. Select “Connect”
  3. Select “Connect with the mongo shell”
  4. Select “I have mongo shell installed”
  5. Set the “mongo shell version to 3.4”
  6. Copy and use the string which should contain the replicaSet value.

Let me know how this goes.

Kind Regards,

1 Like

Error: Authentication failed

In addition to my previous comments, I have also noticed that no authentication database is being passed through when you are connecting with the DNS seed list format which explains this error now.

Hi Jason,

Thanks for pointing my mistake and helping me to look into right direction.

My bad, i was not passing argument -authenticationDatabase admin while connecting through mongo shell or compass.

Issue got resolved and able to do database operations through both medium (Mongo Shell , Compass)

Once again, many thanks fro your prompt assistance.


1 Like

Glad to hear @Kunal_Kumar

As a side note, when connecting using mongoshell and using the DNS seed list format, a DNS TXT Record look up should be performed as well in which the record should contain connection options, to be added as parameters to the dynamically constructed connecting string.

Since these were not being returned whilst you were using the DNS seed list format, it could indicate a possible DNS configuration issue.

One way of testing would be to perform a nslookup as shown in the below example using the cluster you provided in this post:

nslookup -q=TXT

The output should contain the connection options (please note take note of the returned text value):


Non-authoritative answer:	text = "authSource=admin&replicaSet=atlas-11qgt0-shard-0"

Kind Regards,


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.