---
title: "Deploy LibreChat Private AI Chat (MongoDB + Meilisearch)"
description: "Self-hosted AI chat for OpenAI, Claude, Gemini, OpenRouter, agents and RAG."
category: "AI/ML"
url: https://railway.com/deploy/librechat-private-ai-chat-mongodb-meilis
---

# Deploy LibreChat Private AI Chat (MongoDB + Meilisearch)

Self-hosted AI chat for OpenAI, Claude, Gemini, OpenRouter, agents and RAG.

**[Deploy LibreChat Private AI Chat (MongoDB + Meilisearch) on Railway](https://railway.com/template/librechat-private-ai-chat-mongodb-meilis)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/librechat-private-ai-chat-mongodb-meilis/manifest.json

- **Creator:** Templates
- **Category:** AI/ML
- **Total deploys:** 1

## Template content

### MongoDB https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/mongodb.svg

- **Image:** mongo:8.0.38-noble@sha256:76a93cc399d05709baeea4e55385749657aa0085ad5b497c851380778eccea2c
- **Start command:** `docker-entrypoint.sh mongod --ipv6 --bind_ip ::,0.0.0.0 --setParameter diagnosticDataCollectionEnabled=false`

### LibreChat https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/librechat.svg

- **Source:** baranberkay96/librechat-railway
- **Health check:** /health
- **Public domain:** Yes

### rag-api https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/librechat.svg

- **Image:** ghcr.io/danny-avila/librechat-rag-api-dev-lite:v0.9.0@sha256:18a8dffa9316276b924bf3fd23bfb4544b0f68f8f6b14c048affb35c01721a35
- **Start command:** `/bin/sh -c 'if [ -z "${RAG_OPENAI_API_KEY:-}" ]; then case "${OPENAI_API_KEY:-}" in ""|user_provided) echo "[railway] RAG API: no embeddings key (RAG_OPENAI_API_KEY) yet; file search answers with an error until you add one."; export RAG_OPENAI_API_KEY=not-configured ;; *) export RAG_OPENAI_API_KEY="$OPENAI_API_KEY" ;; esac; fi; exec python main.py'`
- **Health check:** /health

### Postgres https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18.6@sha256:4fc833b43d2aaf6ecc9b18615f5533602b723a32d0e2efe2dae8ca0f7217c863

### Meilisearch https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/meilisearch.svg

- **Image:** getmeili/meilisearch:v1.56.2@sha256:9600db22be3fcbf3d506176d3a73dd70a65c5719d9aa1d2837355b75afb8f4fb
- **Start command:** `/bin/sh -c 'k="${MEILI_MASTER_KEY:-}"; if [ -z "$k" ]; then echo "[railway] WARNING: MEILI_MASTER_KEY is empty; using a random key, LibreChat search stays off until you set one."; k=$(head -c 32 /dev/urandom | sha256sum | cut -c1-64); elif [ ${#k} -lt 16 ]; then echo "[railway] WARNING: MEILI_MASTER_KEY is shorter than 16 characters; using its SHA-256 instead."; k=$(printf %s "$k" | sha256sum | cut -c1-64); fi; export MEILI_MASTER_KEY="$k"; exec /bin/meilisearch'`
- **Health check:** /health

## Documentation

# Deploy and Host LibreChat with Railway

LibreChat is an open-source AI chat platform with one interface for OpenAI, Anthropic, Google, OpenRouter and many other model providers, plus agents, file chat (RAG), conversation search and multi-user accounts. This community template runs LibreChat v0.8.8 with MongoDB, Meilisearch and a RAG API on Postgres with pgvector.

## About Hosting LibreChat

LibreChat is a Node.js application. It keeps users, conversations, agents and settings in MongoDB, indexes messages in Meilisearch for full-text search, and sends uploaded documents to its RAG API, which stores embeddings in Postgres with pgvector. This template pins every image to a version and digest, generates all secrets, and creates the administrator account on first start, so the instance is never open for a stranger to claim. Uploads and avatars live on a Railway volume. No model keys are needed to deploy: by default every user adds their own API key in the chat interface, and you can switch to shared keys at any time.

## Common Use Cases

- A private ChatGPT-style workspace for a team, with conversations kept in your own database.
- One interface for several providers (OpenAI, Claude, Gemini, OpenRouter models) with per-user keys.
- Agents with tools and MCP servers, shared inside the team.
- Chat with PDFs and other documents through the built-in RAG API.
- A controlled AI entry point for a company, with accounts managed by an administrator.

## Dependencies for LibreChat Hosting

- LibreChat (`ghcr.io/librechat-ai/librechat:v0.8.8`)
- MongoDB 8.0
- Meilisearch 1.56
- LibreChat RAG API (lite) v0.9.0 with Postgres 18 + pgvector
- Model provider API keys (OpenAI, Anthropic, Google, OpenRouter, ...), added by users or by you

### Deployment Dependencies

- LibreChat documentation: https://www.librechat.ai/docs
- Environment variables: https://www.librechat.ai/docs/configuration/dotenv
- librechat.yaml reference: https://www.librechat.ai/docs/configuration/librechat_yaml
- RAG API: https://www.librechat.ai/docs/configuration/rag_api
- LibreChat source: https://github.com/LibreChat-AI/LibreChat
- Meilisearch: https://www.meilisearch.com/docs

### Implementation Details

| Service | Image | Role | Idle RAM (measured) |
|---|---|---|---|
| `LibreChat` | `librechat:v0.8.8` + Railway launcher | Web app and API, volume `/data` | ~0.35 GB |
| `MongoDB` | `mongo:8.0.38` | Users, chats, agents, settings | ~0.5 GB (0.27 GB under a 0.5 GB limit) |
| `Meilisearch` | `meilisearch:v1.56.2` | Conversation search | ~0.1–0.19 GB |
| `rag-api` | `librechat-rag-api-dev-lite:v0.9.0` | Document parsing and embeddings | ~0.2 GB |
| `Postgres` | `postgres-ssl:18.6` (pgvector) | Vector store for the RAG API | ~0.1 GB |

**First login.** Open the LibreChat domain and sign in with `LIBRECHAT_ADMIN_EMAIL` (default `admin@example.com`) and the generated `LIBRECHAT_ADMIN_PASSWORD`, both on the LibreChat service's Variables tab. The account has the ADMIN role. To use another email, change `LIBRECHAT_ADMIN_EMAIL` before deploying or later (a redeploy creates the new admin). Changing `LIBRECHAT_ADMIN_PASSWORD` and redeploying resets the admin password.

**Accounts.** Public sign-up is off (`ALLOW_REGISTRATION=false`). To onboard a team, set it to `true`, let people register, then set it back to `false`. While sign-up is open, anyone who finds the URL can create an account, so do not leave it open together with shared API keys.

**Model keys.** `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_KEY` and `OPENROUTER_KEY` default to `user_provided`: each user enters their own key from the model menu, and LibreChat stores it encrypted with `CREDS_KEY`. Replace a value with a real key to share it with all users (their usage is then billed to you).

**File chat (RAG).** Embeddings need an OpenAI key on the server: set `RAG_OPENAI_API_KEY` on `rag-api`, or put a real `OPENAI_API_KEY` on LibreChat (the RAG API uses it). Until then, chat works but uploading a file for file search returns an error. Other embedding providers (Azure, Ollama, Hugging Face TEI, Bedrock) are set with `EMBEDDINGS_PROVIDER` and their variables.

**Configuration.** A small `librechat.yaml` is built in (OpenRouter endpoint, welcome text). To use your own, set `CONFIG_PATH` on LibreChat to a raw file URL and redeploy.

**Plans.** Five services, about 1.3 GB RAM in total when idle (MongoDB uses less when its limit is lower). LibreChat and MongoDB were tested with a 0.5 GB limit, as on Railway's Free plan, and stay under it at idle; the other three services idle below 0.2 GB. Trial allows 1 GB per service. For busy teams or large uploads, Hobby or Pro is recommended.

**Scaling.** LibreChat keeps uploads on its volume, so run one replica and give it more memory and CPU as usage grows. MongoDB, Meilisearch and the RAG API scale vertically.

**Pinning and upgrades.** The LibreChat version is the `FROM` line in `services/librechat/Dockerfile` of the template repository; the other images are pinned in the service settings. Read the LibreChat changelog before upgrading. Never change `CREDS_KEY` or `CREDS_IV` after first start, or stored user keys can no longer be decrypted.

### Why Deploy LibreChat on Railway?

Railway runs LibreChat, its databases, search and RAG services together on a private network with HTTPS, volumes and usage-based pricing. You get a private, multi-provider AI chat for your team in one deploy, keep conversations in your own infrastructure, and can grow each service independently.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/librechat-private-ai-chat-mongodb-meilis
