Mongoose Server selection Error

I have 4 VM where Docker containers are running for Node js services which are connecting with MongoDB which are running in a docker container on other 3 VM. when we deploy the service sometimes the only service from 1st VM get connected to mongo sometimes other VM NodeJs service shows the server selection error Shown in the image and all ports are allowed to connect internally within All 7 VM Mongo Version 4.2.8 Node j


s Version 14.2.0 Mongoose Version 5.9.6