#Problems connecting to database

6 messages · Page 1 of 1 (latest)

storm lake
#

Hi, I am running my nestjs backend with mongodb as a docker-compose:

version: '3.4'

services:
  pfbackend:
    image: backend
    environment:
      NODE_ENV: production
    ports:
      - 3000:3000
    depends_on:
      - mongo_db
  mongo_db:
    image: mongo:latest
    environment:
      MONGO_INITDB_ROOT_USERNAME: test
      MONGO_INITDB_ROOT_PASSWORD: test

If I use this connection string:

    MongooseModule.forRoot('mongodb://@mongo_db:27017/test'),

It connects just fine but can't do anything because it isn't authentified
command find requires authentication
But if I add the authentification in the connection string:

MongooseModule.forRoot('mongodb://test:test@mongo_db:27017/test'),

It gives me the classic Unable to connect to the database
So i'm in quite the pickle and I don't know what to try anymore, anyone know ?

desert pewter
storm lake
shut bladeBOT
#

This post has been marked as resolved. :white_check_mark:
Please read through the conversation and resolution if you are having the same issue, and then re-open the post if you are still having trouble, providing as much extra information as possible.

south kernel
desert pewter