Occassional MongoError connection refused with multiple mongodb connection to differnt url

I’m connecting two database located at different url using similar code as below. The problem is occasionally (not every time), when I deploy the application with docker, I’ll receive MongoError saying connection refused to one of the connection at 27017 port. Not sure if this is a known issue to mongdb nodejs driver?

 const url = 'mongo    db://'
      + `${config.secrets.MONGO_USERNAME}:${config.secrets.MONGO_PASSWORD}@`
      + `${config.fileSvcDb.hostPortUrls}/${config.fileSvcDb.name}`
      + `?${config.fileSvcDb.urlOptions}`;

 const options = {
          useUnifiedTopology: true,
          useNewUrlParser: true,
          connectTimeoutMS: 1000,
          serverSelectionTimeoutMS: 50000,
          poolSize: 3
    };

    MongoClient.connectAsync(url1, options)
    MongoClient.connectAsync(url2, options)