Getting Error, "queryServ ENOTFOUND" on Ubuntu


I have been working with Mongo Atlas and connecting to it fine from my local MacBook pro laptop (using the node.js mongodb library).

However, when I try to connect to the database from my remote Ubuntu machine I am never able to connect. :cry:

Here is the error message:

Mongo error:  Error: querySrv ENOTFOUND
[0]     at QueryReqWrap.onresolve [as oncomplete] (dns.js:206:19) {
[0]   errno: 'ENOTFOUND',
[0]   code: 'ENOTFOUND',
[0]   syscall: 'querySrv',
[0]   hostname: ''
[0] }

Anyone else having this issue where they are unable to connect to MongoDB from an Ubuntu server? My connection string looks like this:



Hi @Jim_Lynch have you verified that the IP address of your Ubuntu machine has been whitelisted in Atlas?

I am surprised that your SRV connection string has the following format:

In SRV strings the shard information is usually not present. I would try with


The following should work at as DNS has the following information for your cluster

;; ANSWER SECTION: 59 IN SRV 0 0 27017 59 IN SRV 0 0 27017 59 IN SRV 0 0 27017
1 Like

Thanks @steevej. I had found a random comment on stack overflow that trying to connect to a shard instead of the primary might work, but sadly it didn’t.

Any other ideas for something I can try? :thinking:

Thanks @Doug_Duncan, but I had already added the Ubuntu machine’s IP to the whitelist.

@Jim_Lynch Did you try as he suggested?

Is there a difference in driver version between your host and the ubuntu host ?

Copy the connection string from the clusters connect button on . If you need the older style then select an older version of the driver for the correct string.

You can always connect with a shard URI in your case it would be