Hi, I am a 20+ years programmer. But I am new to MongoDB Atlas and Python. I am using Python 3.9 and PyMongo 4.0.1: I have trouble connect to a free MongoDB Atlas cluster that I have created based on MongoDB instruction. Please see the attached image, my connection string is:
I have replaced with the password for user “behai” in MongoDB Atlas. and I store it as MONGO_CONNECTION_STRING in my keys.py file.
I connect as:
client = pymongo.MongoClient( keys.MONGO_CONNECTION_STRING )
And I have the error:
ConfigurationError: All nameservers failed to answer the query cluster0.71o6u.mongodb.net. IN TXT: Server 192.168.0.1 UDP port 53 answered DNS message is malformed.
If I dropped “+srv” from the connection string, I could connect, but later accesses such as creating a database, creating a collection then insert into the collection would result in error:
When I try to ping cluster0 . 71o6u . mongodb . net:
I would get this response:
Ping request could not find host . Please check the name and try again.
It seems that host “cluster0.71o6u.mongodb.net” does not exist?
But when I look into my MongoDB Atlas windows, I can see I have made 6 connections during last 2 hours:
What am I doing wrong, please? Please help me.
Thank you and best regards,
Be Hai Nguyen.