Cannot connect to MongoDB Atlas Cluster: DNSHostNotFound

Viewed 1656

I created a new cluster in MongoDB Atlas but I can't connect to it thru the mongo shell.

C:\git_symphony\esp8266\SymphonySocket>mongo "mongodb+srv://<clustername>-gy7bf.azure.mongodb.net/test"  --username <USERNAME>
DNSHostNotFound: Failed to look up service "":No records found for given DNS query.
try 'mongo --help' for more information

I tried switching regions but it didn't work. I've also tried using Compass on my mac but it just loads indefinitely when I try to connect. What could possibly be wrong?

3 Answers

I also had this problem with Comcast Xfinity. DHCP sets DNS servers that would not lookup the mongodb connections. I'm running KDE Neon Linux (Ubuntu 18.04). In order to get things working I had to supersede the domain-name-servers supplied through comcast. I used Google's public DNS, but there are others that can be used. I had to edit (you'll need root permissions) the /etc/dhcp/dhclient.conf file, and added to following line: supersede domain-name-servers 8.8.8.8, 8.8.4.4; I hope this helps somebody, took me too long to figure it out. :-)

I just found this post by M. Brandao with the fix for Windows users:

  1. Open the Control Panel.
  2. Click View network status and tasks
  3. Click Change adapter settings on the left portion of the window.
  4. Double-click the icon for the Internet connection you're using.
  5. Click the Properties button.
  6. Click and highlight Internet Protocol Version 4 (TCP/IPv4) and click Properties.
  7. If not already selected, select the Use the following DNS server addresses option.
  8. Enter the new DNS addresses (see above) and click OK and close out of all otherwindows.

Turns out, my ISP blocks all connections to MongoDB for some reason. I haven't contacted them yet, but I find this very silly as I racked my brains out trying to solve this when the problem wasn't at all in my control.

  • Have you whitelisted your IP address ? IP whitelisting is important otherwise it will not connect.
  • Have you created this cluster recently and is it in the europe region ?
  • Is the cluster properly deployed or you are experiencing any issue in the deployment of the cluster ?
Related