Question

I created the mongodb cluster and unable to connect to it , seeing hostnot found error

I created a mongodb cluster and unable to connect to it when using RoboMongo client to connect to it using the connection parameters showin the mongo dashboard . When i ping the host displayed in the connnection string , i am seeing the error No address associated with hostname . is there anything else that i have to do apart from creating the mongodb cluster and creating the database and user ?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 3, 2023

Hi there,

Cluster hostnames do not resolve using standard dig requests to the hostname in the connection string.

MongoDB clusters are hosted on multiple nodes and each has its own hostname. To retrieve the node hostnames of a cluster using dig, you must specify the srv record type in the request and prepend _mongodb._tcp. to the hostname in the connection string like this:

dig srv _mongodb._tcp.<cluster-hostname>

When you connect to your cluster, you need to make sure that you provide the +srv flag in the connection string as follows:

mongo "mongodb+srv://doadmin:<replace-with-your-password>@db-mongodb-nyc3-73883-4aef1b0f.mongo.ondigitalocean.com/admin?authSource=admin&replicaSet=db-mongodb-nyc3-73883" --tls

If you are still unable to connect, you might have locked down the database cluster to a specific set of IP addresses via the Trusted Sources. If this is the case, make sure to add your IP address to the Trusted Sources list as well.

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel