Mongo express container application is not opening

I have created 2 containers mongo express and mongo db containers using below commands

docker run -dit -p 27017:27017 -e MONGO_ROOT_USERNAME=admin -e MONGO_INTDB_ROOT_PASSWORD=password -e PWD=/ -v mongodb-data:/data/db --name mongodb_1 --net my_bridge mongo

docker run -dit -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password --net my_bridge --name mongo_express_1 -e ME_CONFIG_MONGODB_SERVER=mongodb_1 -e ME_CONFIG_BASICAUTH_USERNAME=admin -e ME_CONFIG_BASICAUTH_PASSWORD=admin123456 mongo-express

But I am not able to open application you can see , please suggest what could be the issue

Use 3 backticks before and after code/config to make it more readable and preserve spacing.

When running a container on the same host with docker run -p <port> …, you would usually access it from the host OS with localhost:<port>.

That is what I have tried but I can see not reachable error

I added the windows tags, are you using Docker Desktop or WSL?

I am using Docker Desktop with WSL enabled. and I see following logs from express container:

Welcome to mongo-express 1.0.2
------------------------


Could not connect to database using connectionString: mongodb://admin:****@mongodb_1:27017/"
/app/node_modules/mongodb/lib/cmap/connection.js:227
                    callback(new error_1.MongoServerError(document));
                             ^

MongoServerError: Authentication failed.
    at Connection.onMessage (/app/node_modules/mongodb/lib/cmap/connection.js:227:30)
    at MessageStream.<anonymous> (/app/node_modules/mongodb/lib/cmap/connection.js:60:60)
    at MessageStream.emit (node:events:517:28)
    at processIncomingData (/app/node_modules/mongodb/lib/cmap/message_stream.js:125:16)
    at MessageStream._write (/app/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Socket.ondata (node:internal/streams/readable:809:22)
    at Socket.emit (node:events:517:28) {
  ok: 0,
  code: 18,
  codeName: 'AuthenticationFailed',
  connectionGeneration: 0,
  [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }
}

Node.js v18.20.3
Waiting for mongo:27017...
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Sat Feb 22 08:24:45 UTC 2025 retrying to connect to mongo:27017 (2/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Sat Feb 22 08:24:49 UTC 2025 retrying to connect to mongo:27017 (3/10)

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.