DNSHostNotFound: Failed to look up service

When I am trying to connect to the cluster using Mongo shell I am getting this error :

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

I went through all the threads but still did not find any appropriate solution. Could you please help me out?

Hi @Dheemanth_Narasimha,

Please share the connection string along with the password so that we can test it from our end.


mongo “mongodb+srv://sandbox.wolgr.mongodb.net/myFirstDatabase” --username m001-student

Password : m001-student

Hi @Dheemanth_Narasimha,

I’m able to connect to your cloud cluster using the connection string you provided.

Just to let you know, your given password is incorrect.
The correct one is: m001-mongodb-student which is the suggested one for the M001 university course.

If your problem still persists. try using Google’s or DNS resolvers.
Or, use the non-srv string (found in MDB version 3.4 or less) which you will find in your MongoDB Atlas account’s connection tab by changing the MongoDB version.

Hit ConnectI have the mongo shell installedmongo shell version 3.4 or earlier.

I hope it helps.!

All the Best,

Hey I tried all the above mentioned methods ,even disabled my firewall ,still I am unable to connect to Atlas .

Here s the error log :

{“t”:{"$date":“2021-05-31T12:56:02.313Z”},“s”:“W”, “c”:“CONTROL”, “id”:23321, “ctx”:“main”,“msg”:“Option: This name is deprecated. Please use the preferred name instead.”,“attr”:{“deprecatedName”:“ssl”,“preferredName”:“tls”}}
MongoDB shell version v4.4.6
connecting to: mongodb://sandbox-shard-00-00.wolgr.mongodb.net:27017,sandbox-shard-00-01.wolgr.mongodb.net:27017,sandbox-shard-00-02.wolgr.mongodb.net:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-1la6mi-shard-0
{“t”:{"$date":“2021-05-31T12:56:17.441Z”},“s”:“I”, “c”:“NETWORK”, “id”:4333208, “ctx”:“ReplicaSetMonitor-TaskExecutor”,“msg”:“RSM host selection timeout”,“attr”:{“replicaSet”:“atlas-1la6mi-shard-0”,“error”:“FailedToSatisfyReadPreference: Could not find host matching read preference { mode: “nearest” } for set atlas-1la6mi-shard-0”}}

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

Error: connect failed to replica set atlas-1la6mi-shard-0/sandbox-shard-00-00.wolgr.mongodb.net:27017,sandbox-shard-00-01.wolgr.mongodb.net:27017,sandbox-shard-00-02.wolgr.mongodb.net:27017 :
exception: connect failed
exiting with code 1

Hi @Dheemanth_Narasimha,

Then, there is a high probability that your ISP is blocking port 27017. :no_entry_sign:


Too see if this is the case:

Try to go to http://portquiz.net:27017 in your browser.

1 Like

Hey @steevej,it’s working fine.I am able to reach port 27017.

Here’s the message I received :

Outgoing port tester

This server listens on all TCP ports, allowing you to test any outbound TCP port.

You have reached this page on port 27017 .

Your network allows you to use this port. (Assuming that your network is not doing advanced traffic filtering.)

Network service: unknown

Hi @Dheemanth_Narasimha,

Can you kindly make sure that your IP address is whitelisted. You will find it under the Network Access tab of your MongoDB Atlas Cloud Server.

We suggest you to add (which also includes your current IP address) to your IP Access List under the Security -> Network Access menu within your Atlas Cluster.

NOTE: This isn’t a recommended setting for production environments, but will help with access to your course cluster if you do not have a fixed IP address.

Hope it helps…!!

All the Best,

Hey, I had already whitelisted, and here’s the screenshot of it.

Even after doing that I’m getting the same error.

Hi @Dheemanth_Narasimha,

As per the above error msg, username or password is meant to be incorrect.

Kindly cross check it.


Please revise the lesson Lab: Connect to your Atlas Cluster. If you created you cluster and the user according to the instructions, you should be able to connect by following the lab notes:

Paste the connection string into the IDE terminal tab and establish a connection with your Atlas cluster by executing this connection command and hitting “enter/return” on your keyboard.

You will be prompted to enter the password that you just created:


And just to be clear, you have used m001-student and then m001-mongodb-student as the password rather than m001-mongodb-basics.

Note that the instructions indicate to use the IDE. From you prompt it looks like you are doing that from Windows. You will not be able to validate your labs from Windows.

1 Like

@steevej thanks a ton mate . It’s finally working !!! All this time I was running it on my local mongo shell .How dumb of me.Haha .Thanks a lot for assisting me and thanks to you too @Kushagra_Kesav for replying patiently.

1 Like

Hi @Dheemanth_Narasimha,

We are glad that the issue has been resolved. Meanwhile, your patience is also appreciated. :+1:
As @steevej mentioned use IDE, then only you will be able to pass the lab assignments within the course.

For now, we are closing this thread.
We wish you a happy learning.

All the Best,

1 Like