Chapter 1 - DNSHostNotFound error when trying to connect to application (to Atlas) Ubuntu 18.04

The Problem

Following the prompts for Chapter 1 : Driver Setup I can’t seem to make a connect to my Atlas account. That is I cannot access it locally from my machine.

Configuration

I am not using conda, as I prefer to operate in terminal as often as possible. I’ve confirmed that my Atlas cluster is …

  1. properly named
  2. allowing connection from all locations
  3. user m220student has access, read, and write privileges.

When I try to connect my application using either*

  1. Node.js driver v 3.0 or >
  2. Python v 3.6 or >

Altas provides the following string

mongodb+srv://m220student:<password>@mflix-uovat.mongodb.net/test?retryWrites=true

I replace the substring “” with “m220password” and run the following command in my terminal (virtual environment “ON”)

mongo "mongodb+srv://m220student:m220password@mflix-uovat.mongodb.net/test?retryWrites=true"

Return is:
DNSHostNotFound: Failed to look up service "_mongodb._tcp.mflix-uovat.mongodb.net": Success try 'mongo --help' for more information

I suspect that there is some configuration item I’ve missed or this process has flown over my head. Please help with debugging, where can I start?

Thanks

I am able to connect with and without quotes with the command given by you from shell
May be some config file/ini file issues preventing connection from application

I am also able to connect.

  • Please install MongoDB latest version if you are using an older version.
  • Check if you have firewall enabled, that might be blocking the requests to your cluster.

Kanika

After removing and reinstalling the latest mongoDB and verifying I was not behind a firewall I tried again. With the same error message. I had to reach out to mongoDB directly and they produced a longer connection string…

mongo “mongodb://mflix-shard-00-00-uovat.mongodb.net:27017,mflix-shard-00-01-uovat.mongodb.net:27017,mflix-shard-00-02-uovat.mongodb.net:27017/test?replicaSet=mflix-shard-0” --ssl --authenticationDatabase admin --username --password

Without any explanation why, or where to get this longer connection string. Either way it worked hopefully this can help anyone else having this DNS host issue.

Glad to see that you got it working!

If you can, please share the output of the following command:

 mongo --version

Kanika

MongoDB shell version v4.0.3
git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1804
    distarch: x86_64
    target_arch: x86_64

Unfortunately the advice from MongoDB staff themselves was ultimately not helpful. mongorestore command just hangs forever with this connection string. I would like to see if anyone can help explain the source of a DNS Host Not Found error.

Since you are using a recent mongo you should try connecting with the SRV string. If you go back in atlas it will should tell you the uri. Most likely it will be:

mongodb+srv://USER:PASSWORD@mflix-uovat.mongodb.net/test

My initial attempts were made following the prompts and using the short connection string. When trying to use the short connection string is when I get the DNS host not found error message. See OP

Do you have any other suggestions ? How I can start to trouble shoot this issue ?

The syntax is correct.

  1. Your cluster might be down
  2. Your IP address is not whitelisted

Hi @steevej-1495 ! Is there a way to confirm cluster status?

Eventually I got the short connection string to work. Never fully understood the reason behind the error but simply started with a new cluster. (Worked on the third cluster) Thanks for input and help everyone.