2 / 6
Apr 2024

Hi,

I have the line below in my docker-compose.yml

- ME_CONFIG_MONGODB_URL=mongodb://${UNAME}:${PASSWORDD}@server1.example.com:27001,server2.example.com:27002,server3.example.com:27003/?replicaSet=mongodb-rs1

This gives me the error below.

Could not connect to database using connectionString: mongodb://user1:****@server1.example.com:27001,server2.example.com:27002,server3.example.com:27003/?replicaSet=mongodb-rs1" /app/node_modules/mongodb/lib/sdam/topology.js:285 const timeoutError = new error_1.MongoServerSelectionError(`Server selection timed out after ${serverSelectionTimeoutMS} ms`, this.description); ^ MongoServerSelectionError: getaddrinfo EAI_AGAIN server1

The line below works when I specify it in my docker-compose.yml. However, this will not work if this server is being serviced. I would like to take advantage of the replicaSet.

- ME_CONFIG_MONGODB_URL=mongodb://${RUNAME}:${RPASSWD}@server1.example.com:27001/?directConnection=true

I connect successfully using the command below.

mongosh "mongodb://${UNAME}:${PASSWORDD}@server1.example.com:27001,server2.example.com:27002,server3.example.com:27003/?replicaSet=mongodb-rs1"

Help. I have tried different ways to specify ME_CONFIG_MONGODB_URL.

mongo-express version is 1.0.2-20.

Try to change your config so that the member

_id: 0, name: 'server1:27001',

is specified as

_id: 0, name: 'server1.example.com:27001',