DNSHostNotFound error when connecting with Mongo Shell

When I try to connect to the cluster using Mongo Shell, I get the error :

DNSHostNotFound : Failed to look up service “”: This operation returned because the timeout period expired.

What can be the cause of this?

Information : Mongo shell version v4.0.10
All my firewalls are switched off.

Hey @Herman_52663

Could you share the command you are using that is giving you the error.

I used :

mongo “mongodb+srv://sandbox-qhfg0.mongodb.net/test” --username m001-student --password m001-mongodb-basics

Hi @Herman_52663,

I am able to connect to your cluster using the connection string that you have provided.

mongo “mongodb+srv://sandbox-qhfg0.mongodb.net/test” --username m001-student --password m001-mongodb-basics

Can you please ping the host name mentioned below and share the result (Screenshots).

ping sandbox-shard-00-00-qhfg0.mongodb.net

Thanks,
Shubham Ranjan
Curriculum Support Engineer

I can ping the host name :
image

Hi @Herman_52663,

Can you please try connecting to your sandbox cluster using this connection string

mongo mongodb://sandbox-shard-00-00-qhfg0.mongodb.net:27017,sandbox-shard-00-01-qhfg0.mongodb.net.mongodb.net:27017,sandbox-shard-00-02-qhfg0.mongodb.net:27017/test?replicaSet=Sandbox-shard-0 --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics

Please make sure no additional characters or junk spaces are introduced while you copy-paste this command into your terminal.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

Hello @Shubham_13709

I used the connection string you provided. This is the result :

As you can see it did connect. There was only the error : "Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.] . This however did not prevent me form adding the video database.

Can you tell me why did this connection string work and not the one that MongoDB atlas provided?

Hey @Herman_52663

The error is from the fact that the user that was created does not have the permission to run getlog against the admin db; it only has readWrite permissions on all dbs.

getLog is an administrative command that returns…

To be able to run the getLog command it looks to me as if you need to give the user the clusterMonitor role, or one that includes that role.

Here can see what the readWrtieAnyDatabase role includes; which does not list clusterMonitor

Hope this helps clear things up

Hi, Am facing the same issue connecting to my mongo atlas cluster from my laptop mongo shell. DNSHostNotFound: Failed to look up service “_mongodb._tcp.mflix-uwrha.mongodb.net”: Undefined error: 0

What’s the connection string that you’re using?

Hi @pmuthyala,

Please share the connection string along with the password as requested by @007_jb so that we can test it from our end.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Hi Herman_52663,

I also got the sandbox connected with the same connection string. If you don’t mind can you please tell how you got the connection string you used which is:
mongo “mongodb+srv://sandbox-qhfg0.mongodb.net/test” --username m001-student --password m001-mongodb-basics

In the online lectures it is given as:
mongo “mongodb+srv://sandbox-xxxxx.mongodb.net/test” --username m001-student --password m001-mongodb-basics

Thanks
Arun

Sandbox cluster means it is your own cluster

You have to create this
Did you complete the task setting up Sandbox cluster from Atlas

mongo “mongodb+srv://sandbox-xxxxx.mongodb.net/test” --username m001-student --password m001-mongodb-basics

xxxx is just a placeholder in the above string
Each student wil have a unique clustername

Please check your lectures again

1 Like

HI @ARUN_CHANDY,

If you haven’t already created your own sandbox cluster then please create one.

Once you have created your own sandbox cluster then please follow the instructions mentioned in this video lecture :point_down: for getting the connection string and connecting to it.

Chapter 2 : Connecting to Your Sandbox Cluster from the mongo Shell

~ Shubham

Hello, I had this same issue and have followed your steps and believe I have solved the issue however, i am not to sure if I should be doin g something next?

Step 1.After amending my path initial path, it still never worked. I then took the path you provided to this user and replaced the XXXX field with my character

Step 2. the path has run successfully but I am not sure if I need to do anything more to get my shell to read sandbox?

Good you were able to connect to your Sandbox cluster successfully with long string
Nothing needs to be done
Just run some commands like show dbs,db,show collections

From where you got the first connect string.Something is missing there
Are you trying SRV string?

Try this

mongo mongodb+srv://m001-student:m001-mongodb-basics@sandbox-raweq.mongodb.net/test

1 Like

Great, thank you for your help . it worked

14 posts were split to a new topic: DNSHostNotFound: Failed to look up service