Home > Back-end >  Bitnami docker image | MongoNetworkError: connect ECONNREFUSED 172.20.0.2:27017
Bitnami docker image | MongoNetworkError: connect ECONNREFUSED 172.20.0.2:27017

Time:05-25

I'm trying to deploy the container with the "Bitnami docker image" for later, can link this with my app.

My docker-compose.yml:

version: '3.9'

services:

# Database service
      mongodb:
          image: 'bitnami/mongodb:5.0.8'
          container_name: mongodb
          restart: always
          env_file:
              - ./.env
          ports:
            - "27017:27017"

I just wanna run the database, and later link with my app, but i don't know what happen, bc when i run the command "docker-compose up", the terminal throw me this error:

Attaching to mongodb
mongodb  | mongodb 09:52:16.48 
mongodb  | mongodb 09:52:16.48 Welcome to the Bitnami mongodb container
mongodb  | mongodb 09:52:16.48 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-mongodb
mongodb  | mongodb 09:52:16.48 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-mongodb/issues
mongodb  | mongodb 09:52:16.49 
mongodb  | mongodb 09:52:16.49 INFO  ==> ** Starting MongoDB setup **
mongodb  | mongodb 09:52:16.51 INFO  ==> Validating settings in MONGODB_* env vars...
mongodb  | mongodb 09:52:16.54 INFO  ==> Initializing MongoDB...
mongodb  | mongodb 09:52:16.56 INFO  ==> Deploying MongoDB from scratch...
mongodb  | MongoNetworkError: connect ECONNREFUSED 172.20.0.2:27017

My .env file:

MONGO_INITDB_ROOT_USERNAME=You
MONGO_INITDB_DATABASE=YourDataBaseName
MONGO_INITDB_ROOT_PASSWORD=YourPassword

Anyone can help me?, Thanks in advance.

CodePudding user response:

It's not an error. In one of the startup scripts by bitnami, it waits until MongoDB starts well. This message should have been suppressed by bitnami. They wait until it starts well, or timeout.

In this case, it tries one time and this message came when it did not start. The second time, Mongodb started. And, it moves ahead.

  • Related