Skip to content

Enhancement: allow users to setup password on mongodb #1723

@CXwudi

Description

@CXwudi

What features would you like to see added?

Support username and password for mongo DB from docker compose

More specifically, support the following mongo DB URI format in MONGO_URI environment variables:

mongodb://<username>:<password>@<host>/<database>

More details

command: mongod --noauth

It is not secured to run any database without a password.

However, currently LibreChat doesn't support locally hosted mongo DB with a password. Doing so will results in the following error:

[email protected] backend
cross-env NODE_ENV=production node api/server/index.js

2024-02-04 16:42:15 info: [Optional] Redis not initialized. Note: Redis support is experimental.
2024-02-04 16:42:19 error: KeyvMongo connection error: Authentication failed.
2024-02-04 16:42:19 error: There was an uncaught error: Authentication failed.

The example docker compose yaml file I used is following:

  librechat:
    # librechat configs...

  mongodb:
    image: mongo
    container_name: librechat-mongodb
    environment:
      - MONGO_INITDB_ROOT_USERNAME=my_admin
      - MONGO_INITDB_ROOT_PASSWORD=my_password
    volumes:
      - librechat-mongodb-data:/data/db

And for the LibreChat config, I simply set MONGO_URI=mongodb://my_admin:my_password@mongodb:27017/LibreChat

Which components are impacted by your request?

General

Pictures

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions