Unable to connect using replicas uri (docker setup)

Hi,

I wasn’t able to resolve it. I just tried with the latest version of mongo 5.0.6 and mongoose 6.2.3 and it still doesn’t work.

This is the latest error I got when trying to connect

MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
    at NativeConnection.Connection.openUri (C:\mongoose-ttl\node_modules\mongoose\lib\connection.js:846:32)
    at C:\mongoose-ttl\node_modules\mongoose\lib\index.js:351:10
    at C:\mongoose-ttl\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:5
    at new Promise (<anonymous>)
    at promiseOrCallback (C:\mongoose-ttl\node_modules\mongoose\lib\helpers\promiseOrCallback.js:30:10)
    at Mongoose._promiseOrCallback (C:\mongoose-ttl\node_modules\mongoose\lib\index.js:1149:10)
    at Mongoose.connect (C:\mongoose-ttl\node_modules\mongoose\lib\index.js:350:20)
    at run (C:\mongoose-ttl\index.js:10:20)
    at Object.<anonymous> (C:\mongoose-ttl\index.js:7:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: 'rs0',
    maxSetVersion: 1,
    maxElectionId: 7fffffff0000000000000001,
    servers: Map(3) {
      'mongo-primary:27017' => [ServerDescription],
      'mongo-secondary:27017' => [ServerDescription],
      'mongo-arbiter:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: 13
  }
}

The error seems to be much better, but it still wouldn’t work and I have no idea what is causing it

I also have tried what others has said worked in various places, but I just couldn’t get it to work, and it doesn’t help that no one seem to be helping out here (in this forum).

I know that the setup is correct because if I connect to only the primary instance, and created a document, the other instances will have the document replicated but I just couldn’t connect if using the entire connection string like such mongodb://localhost:30000,localhost:30001,localhost:30002/ttt?replicaSet=rs0

If anyone is able to get it to work, I would love to know what am I missing that is not working