Can't connect to MongoDB Atlas - querySrv ENOTFOUND

Hi all,

First of all, if this is not the right category, please let me know which one is.

I’m new to MongoDB. Made a local deploy and it’s running fine. Now I’m trying to set up an Atlas instance, but can’t seem to be able to connect to it.
I’m trying to use the string


as suggested in the “connect” session in Atlas console, however, when I enter this string in Compass I get the error


I’ve also tried connecting through mongosh and get the same error

C:\Users\OS16S8898>mongosh “mongodb+srv://” --username pdantas
Enter password: *******
Current Mongosh Log ID: 6165e8a56936fb42f0cbf229
Connecting to: mongodb+srv://
Error: querySrv ENOTFOUND

I’ve whitelisted my IP, and even added to the IP access list, to no avail. Can someone please help me find out what is it that I’m doing wrong?


1 Like

Hi @Pedro_Dantas,

Which versions are you using?

  • Compass
  • MongoDB Atlas cluster
  • Mongosh

Also, this topic had a solution:

Does it work for you too?

1 Like

Try using google’s DNS and

See Public DNS  |  Google Developers for more details.


Hi @MaBeuLux88.

  • Compass 1.28.4
  • MongoDB Atlas cluster 4.4.9
  • Mongosh 1.1.0

Those were the latest versions that I could find.

About the solution detailed in the link, I tried formatting the string as instructed (using the mongodb protocol and a lista of the URLs for each shard separated by a comma) but still can’t get a connection (it does seem to be able to resolve the IP address, though).

C:\Users\OS16S8898>mongosh mongodb://,,
Current Mongosh Log ID: 6166f8446f2747e87b767609
Connecting to:          mongodb://<credentials>,,
MongoServerSelectionError: connection <monitor> to closed

Am I still missing something?


Hi @steevej I added those IP’s to the whitelist but nothing happened, was I supposed to do something else?


The 2 IPs I provided are not at all related to the white list of your cluster. It has to do with host name resolution, aka DNS. In the link I provided you will find instructions for

Configure your network settings to use the IP addresses and as your DNS servers.

Your ISP or VPN provider probably uses old DNS software that cannot resolve SRV connection strings.

I have just notice that your original post contains 2 different connection strings, one with c0tbu and one with n2hlh.

Make sure to retrieve the Compass connection string from the MongoDB Atlas UI like this:

Of course make sure to change the values for the username and password.
They come from this menu. It’s not the Atlas user/pwd.

In the end, it should look like this:


Try to connect using the above connection string in Compass to see if it works. This is the public cluster where I’m hosting the Open Data COVID-19 data set.

If that doesn’t work - then you have a DNS problem like @steevej explained and you have to add and/or in your DNS list.

For me on linux, I would have to add on the first line of /etc/resolv.conf:

<keep the former DNS line in here>



Hi guys,

I was already using the connection string provided by the Atlas console, to no avail.
I changed the DNS to Google’s

SSID:	Pivonet 5G
Protocol:	Wi-Fi 5 (802.11ac)
Security type:	WPA2-Personal
Network band:	5 GHz
Network channel:	100
IPv6 address:	2001:818:e348:c700:2093:b4f9:eef:80a8
Link-local IPv6 address:	fe80::2093:b4f9:eef:80a8%19
IPv6 DNS servers:	2001:4860:4860::8888
IPv4 address:
IPv4 DNS servers:
Manufacturer:	Intel Corporation
Description:	Intel(R) Wireless-AC 9560 160MHz
Driver version:
Physical address (MAC):	84-C5-A6-6A-70-6B

but it’s still not working

I also tried to connect to the Covid19 DB as suggested by Maxime but get the same error.

However, I found out that I do can connect through mongoshell :smiley:

C:\Users\OS16S8898>mongosh mongodb+srv://
Current Mongosh Log ID: 61680c1143666d0fa2a10a77
Connecting to:          mongodb+srv://<credentials>
Using MongoDB:          4.4.9
Using Mongosh:          1.1.0

For mongosh info see:

Atlas covid-19-shard-0 [primary] covid19>

So I’m guessing I can work through here, but if you have any further idea on why the connection though Compass isn’t working I’d love to hear, as I’d rather work that way if possible.

Thanks for the assistance so far :slight_smile:


1 Like

Can you connect to


Using MongoDB Compass?

@MaBeuLux88 No, as I said I get the same error

What’s your OS & are you up-to-date ? Looks like there is definitely something wrong with your Internet connection. Are you behind a VPN maybe? Firewall? Or maybe it’s just a DNS issue as @steevej suggested.
Can you try a different internet connection & disable everything than can cause connection issues? Antivirus software can block connections sometimes as well. If it works reactive them one by one and eliminate the troublemaker :smiley: !


On my side I was having the same issue and by disabling my VPN, the connection worked.

Due to work, I need to use a VPN so how can we fix this issue other than disabling the VPN?

Your work probably disabled connections to port 27017 or maybe they have even more restrictive rules in place. You need to talk to your IT support. Pity that your work system & network doesn’t allow you to work :sweat_smile:. I guess they are just missing an exception on this port in their gateway rules. But I’m not an expert :confused:.

Try to see if it is the above.

This is happening to me now after Windows automatically updated to version 10.0.19042 Build 19042.

Last night things were working fine, got up today and my machine had restarted & updated. Skipped Windows 11 spam at startup, started up my dev environment in WSL1 like always, and now I can’t work. Anyone else experiencing this?

I can connect with Compass just fine.

I’m not connected to VPN (which does mess up connections to Atlas, although with a different error). Until today I have never seen the error in OP’s post.

telnet 27017 is failing, so I’m guessing something in the Windows update affected Windows Defender.

Couldn’t ping either.


This worked for me: edit /etc/wsl.conf and set generateResolvConf = true

Thanks, here it worked.

1 Like

I have the same problem because I was connected to a VPN, when I disconnect it it works immediately.

1 Like

Having run into a host of issues using private endpoints, some or most self inflicted, I have come the assumption that the “Error: querySrv ENOTFOUND” has to do with the inability of the driver to resolve a FQDN of the “mongodb+srv” to names of the replica set members.


The error generally indicates the FQDN for the associated host(s) for the SRV record were not able to be resolved by the DNS in use.

As of the time of this message, the SRV record prefix for Atlas clusters is _mongodb._tcp.

Below is a reproduction that shows this error. Let’s say I have a cluster which has an associated SRV record which resolves to the following hostnames:

nslookup -type=SRV

Non-authoritative answer:	service = 0 0 27017	service = 0 0 27017	service = 0 0 27017

Although not exactly the case for all similar errors generated and only for demonstration purposes, I will pass through an invalid SRV record (to some degree attempt to mimic the DNS being unable to resolve the SRV records):

nslookup -type=SRV

** server can't find NXDOMAIN

Using the DNS seed list connection format with the invalid SRV record above in Compass results in the querySrv ENOTFOUND error:

In conclusion, the error querySrv ENOTFOUND was caused by DNS resolving issues, likely from the client side. Also as several people have noted in this thread, if you’re using VPN and encountering this issue only on the VPN (i.e. Connection works fine without querySRV error outside of the VPN connection) then it is probably due to how the VPN is configured. To my knowledge there are some VPN’s which assign a new DNS for the VPN session which could result in this error.