pymongo.errors.ServerSelectionTimeoutError: cluster0.k1xw6gs.mongodb.net:27017: [Errno 11001] getaddrinfo failed, Timeout: 30s, Topology Description: <TopologyDescription id: 656ed8c2f0e1053888305ed5, topology_type: Single, servers: [<ServerDescription (‘cluster0.k1xw6gs.mongodb.net’, 27017) server_type: Unknown, rtt: None, error=AutoReconnect(‘cluster0.k1xw6gs.mongodb.net:27017: [Errno 11001] getaddrinfo failed’)>]>
I have following settings.py in Django
DATABASES = {
"default": {
"ENGINE": "djongo",
"CLIENT": {
"name" : "db_name",
"host": "cluster0.k1xw6gs.mongodb.net",
"username": "username",
"password": "password",
"authMechanism": "SCRAM-SHA-1",
"authSource": "admin",
},
}
}
When it is pinged from cmd
ping cluster0.k1xw6gs.mongodb.net
Following error is recieved:
Ping request could not find host cluster0.k1xw6gs.mongodb.net. Please check the name and try again.
I have following Versions of Packages:
Django==4.0.1
djongo==1.3.6
pymongo==3.12.3
Tried a solution too : Navuagted to virtualEnv/Lib/pymongo/mongo_client.py
and Changed the HOST="localhost"
to
HOST="mongodb+srv://my_db_user_name:my_db_password@cluster0.k1xw6gs.mongodb.net/my_db_name?retryWrites=true&w=majority"
But the error is still there…
PS : using the link mongodb+srv://my_db_user_name:my_db_password@cluster0.k1xw6gs.mongodb.net
in mongosh worked pretty fine and totally worked but not working in my Django Project.
I Want to migrate my database to mongo using python manage.py migrate
I also have whitelisted my own Ip and 0.0.0.0 to the Ip access list.
Please any lead. Thank you very much in advance