Docs
Configuration
MongoDB
MongoDB Atlas

Setting Up an Online MongoDB Database

1. Create a MongoDB Atlas Account

  1. Open a new tab in your web browser and go to account.mongodb.com/account/register.
  2. Fill out the required information and create your account.

2. Create a New Project

  1. After setting up your account, click on the “New Project” button and give it a name (e.g., “LibreChat”).

3. Build a Database

  1. Click on the “Build a Database” button.

4. Choose the Free Tier

  1. Select the “Shared Clusters” option, which is the free tier.

5. Name Your Cluster

  1. Give your cluster a name (e.g., “LibreChat-Cluster”) and click “Create Cluster”.

6. Set Up Database Credentials

  1. Click on the “Database Access” option in the sidebar.
  2. Click on the “Add New Database User” button.
  3. Enter a username and a secure password, then click “Add User”.

7. Configure Network Access

  1. Click on the “Network Access” option in the sidebar.
  2. Click on the “Add IP Address” button.
  3. Select “Allow Access from Anywhere” and click “Confirm”.

8. Get Your Connection String

  1. Click on the “Databases” option in the sidebar.
  2. Click on the “Connect” button.
  3. Select “Connect Your Application”.
  4. Copy the connection string provided.
  5. Replace <password> in the connection string with the password you set in Step 6. Remove the <> characters around the password.
  6. Remove &w=majority from the end of the connection string.
  7. Add your desired database name (e.g., “LibreChat”) after the host name in the connection string.

Your final connection string should look something like this:

Connection String
mongodb+srv://username:[email protected]/LibreChat?retryWrites=true

9. Update the .env File

  1. In your LibreChat project, open the .env file.
  2. Find the MONGO_URI variable and paste your connection string:
.env
MONGO_URI=mongodb+srv://username:[email protected]/LibreChat?retryWrites=true

That’s it! You’ve now set up an online MongoDB database for LibreChat using MongoDB Atlas, and you’ve updated your LibreChat application to use this database connection. Your application should now be able to connect to the online MongoDB database.

Note about Docker

✏️
Docker

Note: If you’re using LibreChat with Docker, you’ll need to utilize the docker-compose.override.yml file. This override file allows you to prevent the installation of the included MongoDB instance. Instead, your LibreChat Docker container will use the online MongoDB Atlas database you’ve just set up. For more information on using the override file, please refer to our Docker Override Guide.