I have created a mongo-express container using docker terminal command line and connect my mongodb using security authentication enabled:
docker run -d --name mongo-express -e ME_CONFIG_MONGODB_SERVER=localhost -e ME_CONFIG_MONGODB_PORT=27017 -e ME_CONFIG_MONGODB_ADMINUSERNAME=root -e ME_CONFIG_MONGODB_ADMINPASSWORD=password -p 2053:8081 mongo-express
However, it seems not connected to my local mongodb user credentials. Here is my error logs:
docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:48 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
Thu Mar 20 15:44:49 UTC 2025 retrying to connect to mongo:27017 (3/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:50 UTC 2025 retrying to connect to mongo:27017 (4/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:51 UTC 2025 retrying to connect to mongo:27017 (5/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:52 UTC 2025 retrying to connect to mongo:27017 (6/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:53 UTC 2025 retrying to connect to mongo:27017 (7/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:54 UTC 2025 retrying to connect to mongo:27017 (8/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:55 UTC 2025 retrying to connect to mongo:27017 (9/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
Thu Mar 20 15:44:56 UTC 2025 retrying to connect to mongo:27017 (10/10)
/docker-entrypoint.sh: line 15: mongo: Name does not resolve
/docker-entrypoint.sh: line 15: /dev/tcp/mongo/27017: Invalid argument
No custom config.js found, loading config.default.js
Welcome to mongo-express 1.0.2
------------------------
Could not connect to database using connectionString: mongodb://root:****@localhost:27017/"
/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: connect ECONNREFUSED ::1:27017
at Timeout._onTimeout (/app/node_modules/mongodb/lib/sdam/topology.js:285:38)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) {
'localhost:27017' => ServerDescription {
address: 'localhost:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 130249877,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (/app/node_modules/mongodb/lib/cmap/connect.js:387:20)
at Socket.<anonymous> (/app/node_modules/mongodb/lib/cmap/connect.js:310:22)
at Object.onceWrapper (node:events:632:26)
at Socket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
cause: Error: connect ECONNREFUSED ::1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 27017
},
[Symbol(errorLabels)]: Set(1) { 'ResetPool' }
},
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
'$clusterTime': null
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
}
Node.js v18.20.3
How can I make it to connect successfully?