Having trouble connecting to Mongo DB from hosting server


I am having trouble connecting to my MongoDB database from my hosting server at Heliohost.org. The server is running python 3.10.8 and all required dependencies have been installed. Port 27017 have also been opened for the primary and two secondary domain IPs i.e.

  1. radtech-shard-00-01.p4cyn.mongodb.net ( )
  2. radtech-shard-00-00.p4cyn.mongodb.net ( )
  3. radtech-shard-00-02.p4cyn.mongodb.net ( )

My script managed to connect to the database from my local machine without problem but it failed to connect from the hosting server. My connection string used is:


I tried to get help from the server admins and the following are some of the feedbacks i got from them:

  1. The script you listed is trying to connect to radtech.p4cyn.mongodb.net which doesn’t exist, or at least there is no DNS for it…
  2. You can’t connect to a website that doesn’t return an A record. Either connect to it directly by IP address, ie:, or come up with a new URL that actually exists…
  3. It doesn’t resolve for me either against any DNS server I’ve tried… A normal lookup (A) returns no value, and doing an ALL lookup returned a single TXT record… You need to either: Use an IP address directly, use a URL whose DNS zone actually has an A record in it, or contact the database host and ask them to fix their DNS zone…
  4. What we don’t understand is how this is working for you without an A record present, unless it’s doing something weird like only responding for requests in a certain part of the world (we are both in the USA, as is our server), or perhaps it’s using a SRV record instead?..
  5. You can use this tool https://dnschecker.org/#A/radtech.p4cyn.mongodb.net to check A records from 33 DNS servers all around the world. They all report that there is no A record for that domain…

Sorry as i’m pasting here the comments verbatim because i’m not that good at re-explaining this myself… i’m not really familiar with everything about DNS records, so could someone explain what is all this about? Why am i not able to connect to the database from my hosting server? what can/should my hosting server do to allow me to connect to MongoDB host ?

Thanks in advance…

please check your database server’s network access settings. it is possible you have strict IP access allowing only your local machine’s IP.

Unless you have configured Atlas to allow all IP addresses(which you shouldn’t do). You will need to add IP addresses of the servers that will be connecting to your Atlas cluster.

Pymongo only added dnspython as a dependency in 4.3.2 so prior to this version dnspython would have to be added to requirements.txt, this is one thing to check.

Atlas Documentation describes how to connect.

Server admins 3 and 4 got close. The mongodb+srv:// connection string is used to resolve both SRV records AND a txt record. You can read more at Connection String URI Format

I can confirm that i am allowing all IP addresses to connect to my cluster.

So far, access from all IP addresses are allowed and dnspython has been installed.

Currently i have only requested for port 27017 to be opened… do i need to request for ports 27015 and 27016 to be opened too if i’m connecting to my cluster using the following connection string?

Welcome to the MongoDB Community @ra_rahim !

The hostnames you have provided all appear to be resolvable. If this was a newly created cluster, it is possible the hostnames have not propagated to your local DNS servers yet.

If possible I would try using different name servers, for example Google Public DNS.

The mongodb+srv connection string format uses SRV and TXT records to discover the cluster hostnames and connection settings. For more background, see MongoDB 3.6: Here to SRV you with easier replica set connections | MongoDB.

This is correct for any of the hostnames in your replica set. You need to use the Atlas hostnames (and ideally, the SRV url) to connect to your cluster.

Google Public DNS is generally a good starting point.

This suggestion incorrectly assumes that an SRV hostname will have an A record (it will not, as above).

One of my colleagues wrote a small tool to try to help checking Atlas connections. I suggest trying to run this from your host server environment: GitHub - pkdone/mongo-connection-check: Tool to check the connectivity to a remote MongoDB deployment, providing advice if connectivity is not achieved.

For an Atlas replica set, you will only need access to port 27017. Port 27016 is used for sharded clusters and port 27015 for the MongoDB Connector for BI. For a reference, please see Attempting to connect to an Atlas deployment from behind a firewall.