mongo-express / mongo-express-docker

a dockerized mongo-express for viewing mongoDB in the browser
MIT License
203 stars 93 forks source link

Could not connect to database using connectionString #125

Open jyanga opened 7 months ago

jyanga commented 7 months ago

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.

xTudoS commented 4 months ago

Hello! Did you tried to run mongoexpress outside a docker container, and see if the error continues? Or tried to build your own docker image?

Docker hub version is out-of-date

mariuskempf commented 3 months ago

I am having a very similar issue, where I deploy the image from Docker-Hub to Kubernetes. I keep running into these timeouts while using the CLI or PyMongo, I am able to connect to the replica/server

jyanga commented 3 months ago

@mariuskempf Here is the solution to this issue.

https://www.mongodb.com/community/forums/t/could-not-connect-to-database-using-connectionstring/275178

xTudoS commented 3 months ago

thank you @jyanga did it work @mariuskempf ?