Skip to content

Couldn't connect with example stack.yml from documentation #578

Description

@LeeviHalme

I am simply running docker-compose up -d using the compose file found on the docker page of mongo (https://hub.docker.com/_/mongo/) under the title "... via docker stack deploy or docker-compose"

docker-compose.yml:

# Use root/example as user/password credentials
version: '3.1'

services:

  mongo:
    image: mongo
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  mongo-express:
    image: mongo-express
    restart: always
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example
      ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
Output of running docker-compose logs

mongo-express_1  | Welcome to mongo-express
mongo-express_1  | ------------------------
mongo-express_1  | 
mongo-express_1  | 
mongo-express_1  | (node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
mongo-express_1  | Could not connect to database using connectionString: mongodb://root:example@mongo:27017/"
mongo-express_1  | (node:7) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [mongo:27017] on first connect [MongoNetworkTimeoutError: connection timed out
mongo-express_1  |     at connectionFailureError (/node_modules/mongodb/lib/core/connection/connect.js:362:14)
mongo-express_1  |     at Socket. (/node_modules/mongodb/lib/core/connection/connect.js:330:16)
mongo-express_1  |     at Object.onceWrapper (events.js:420:28)
mongo-express_1  |     at Socket.emit (events.js:314:20)
mongo-express_1  |     at Socket._onTimeout (net.js:483:8)
mongo-express_1  |     at listOnTimeout (internal/timers.js:554:17)
mongo-express_1  |     at processTimers (internal/timers.js:497:7)]
mongo-express_1  |     at Pool. (/node_modules/mongodb/lib/core/topologies/server.js:441:11)
mongo-express_1  |     at Pool.emit (events.js:314:20)
mongo-express_1  |     at /node_modules/mongodb/lib/core/connection/pool.js:564:14
mongo-express_1  |     at /node_modules/mongodb/lib/core/connection/pool.js:1000:11
mongo-express_1  |     at /node_modules/mongodb/lib/core/connection/connect.js:32:7
mongo-express_1  |     at callback (/node_modules/mongodb/lib/core/connection/connect.js:300:5)
mongo-express_1  |     at Socket. (/node_modules/mongodb/lib/core/connection/connect.js:330:7)
mongo-express_1  |     at Object.onceWrapper (events.js:420:28)
mongo-express_1  |     at Socket.emit (events.js:314:20)
mongo-express_1  |     at Socket._onTimeout (net.js:483:8)
mongo-express_1  |     at listOnTimeout (internal/timers.js:554:17)
mongo-express_1  |     at processTimers (internal/timers.js:497:7)

Waiting for MongoDB to start up wasn't the issue. It was still failing to connect after 10 minutes

Any ideas how to fix this? Host machine is running Ubuntu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions