i am getting this error while connecting to mongodb Atlas: "dns.exception.Timeout: The DNS operation timed out after 30.000985383987427 seconds" i am getting this error while connecting to mongodb Atlas: "dns.exception.Timeout: The DNS operation timed out after 30.000985383987427 seconds" mongodb mongodb

i am getting this error while connecting to mongodb Atlas: "dns.exception.Timeout: The DNS operation timed out after 30.000985383987427 seconds"


Try using a different connection string. I was having problems with the 3.6 or later string. Simply used the 3.4 or later string and it connected instantly.

if you insist on using a newer connection string, you need to install pymongo srv

For Windows

pip install pymongo[srv]

For Mac

pip3 install pymongo[srv]

On zsh

pip3 install 'pymongo[srv]'


Looks like you have to install pymongo[srv] to get mongodb+srv URI to work.
Try installing it with pip3 install 'pymongo[srv]'


It might be an error caused while your Mongo Client is unable to find the connection to the server. So, better check you internet connectivity and then run the program