'pymongo MongoClient connection failed due to pymongo.errors.ServerSelectionTimeoutError: mongo1:27017: [Errno -3] Temporary failure in name resolution
I have installed 3 node mongodb with replicaset.
Docker images are started to bind all ip address.
command: mongod --replSet engline-rs --journal --bind_ip_all
I am able to connect the database using
mongodb://admin:password@localhost:27017/?authSource=admin
in robo3T or mongodb compass. But with the same uri my python code is not able to connect to the server.
Got below error:
pymongo.errors.ServerSelectionTimeoutError:
mongo1:27017: [Errno -3] Temporary failure in name resolution,
mongo3:27017: [Errno -3] Temporary failure in name resolution,
mongo2:27017: [Errno -3] Temporary failure in name resolution,
Timeout: 30s,
Topology Description: <TopologyDescription id: 6268ec793318f4b4ce36f100,
topology_type: ReplicaSetNoPrimary,
servers: [<ServerDescription ('mongo1', 27017)
server_type: Unknown, rtt: None,
error=AutoReconnect('mongo1:27017: [Errno -3] Temporary failure in name resolution')>,
<ServerDescription ('mongo2', 27017)
server_type: Unknown, rtt: None,
error=AutoReconnect('mongo2:27017: [Errno -3] Temporary failure in name resolution')>,
<ServerDescription ('mongo3', 27017)
server_type: Unknown, rtt: None,
error=AutoReconnect('mongo3:27017: [Errno -3] Temporary failure in name resolution')>]>
Any help is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
