---
title: "Deploy LibreChat"
description: "Self-hosted LibreChat: GPT, Claude, Gemini in one app. ChatGPT alternative."
category: "AI/ML"
url: https://railway.com/deploy/librechat-self-hosted
---

# Deploy LibreChat

Self-hosted LibreChat: GPT, Claude, Gemini in one app. ChatGPT alternative.

**[Deploy LibreChat on Railway](https://railway.com/template/librechat-self-hosted)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/librechat-self-hosted/manifest.json

- **Creator:** SilverBanana
- **Category:** AI/ML

## Template content

### VectorDB https://devicons.railway.com/i/postgresql.svg

- **Image:** pgvector/pgvector:pg17

### Meilisearch https://raw.githubusercontent.com/meilisearch/meilisearch/909ef7fef5ba264dc914c4778d6328c5edca5ca7/assets/logo.svg

- **Image:** getmeili/meilisearch:v1.35.1

### MongoDB https://devicons.railway.com/i/mongodb.svg

- **Image:** mongo:8.0
- **Start command:** `docker-entrypoint.sh mongod --ipv6 --bind_ip_all`

### rag-api https://raw.githubusercontent.com/LibreChat-AI/LibreChat/9e74cc0e57b395926122bd4062c1fcedc48ed465/client/public/assets/icon-192x192.png

- **Image:** ghcr.io/danny-avila/librechat-rag-api-dev-lite:latest
- **Start command:** `/bin/sh -c 'export RAG_OPENAI_API_KEY="${RAG_OPENAI_API_KEY:-not-set}"; exec python main.py'`

### LibreChat https://raw.githubusercontent.com/LibreChat-AI/LibreChat/9e74cc0e57b395926122bd4062c1fcedc48ed465/client/public/assets/icon-192x192.png

- **Source:** dektionstudio/railway-template-images
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host LibreChat on Railway

![LibreChat chat interface with model picker and conversation history](https://raw.githubusercontent.com/LibreChat-AI/librechat.ai/main/components/home/img/demo_dark.png)

LibreChat is the open-source AI chat platform with **46,000+ GitHub stars**: one ChatGPT-style interface for OpenAI, Anthropic, Google, OpenRouter and many more models, with agents, file search and conversation history. ChatGPT Business and Claude Team cost $20–25 per seat per month — self-host LibreChat on Railway for ~$12–20/month plus the API usage you actually pay for, and keep every conversation in your own database.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **LibreChat** | Web app and API (port 3080, public HTTPS domain, `/health` check). Built from the template's GitHub source; creates an admin account on first start. |
| **MongoDB** | MongoDB 8. Stores users, conversations, messages, presets and agents. |
| **Meilisearch** | Meilisearch v1.35 for full-text search across your conversations. |
| **rag-api** | LibreChat RAG API (lite) — embeds uploaded files so you can chat with PDFs and documents. |
| **VectorDB** | PostgreSQL 17 with pgvector. Stores file embeddings for the RAG API. |
| **Persistent Volume** | `/data` on LibreChat — uploads, generated images and logs. |
| **Persistent Volume** | `/data/db` on MongoDB and `/var/lib/postgresql/data` on VectorDB — conversations and embeddings survive redeploys. |

Five services on Railway's private network. Only LibreChat is public; databases, search and the RAG API are internal.

---

## About Hosting LibreChat

A complete LibreChat install needs the app, MongoDB, Meilisearch for search, a RAG API and a vector database for file chat, plus secrets in exact formats: `CREDS_KEY` must be 64 hex characters and `CREDS_IV` 32. Getting all of that right by hand takes Docker Compose, a reverse proxy and careful key generation.

On Railway, all five services start together, LibreChat gets an HTTPS domain, `DOMAIN_CLIENT` and `DOMAIN_SERVER` point at it automatically, and every secret is generated in the correct format. Registration is closed by default, and an admin account is created from `ADMIN_EMAIL` on first start.

**File search needs an OpenRouter key.** The RAG API creates embeddings through OpenRouter using `OPENROUTER_KEY` from the LibreChat service. Leave it empty and chat still works with per-user keys, but uploading files for search won't.

Typical cost: **~$12–20/month** on Railway for the stack, plus the AI API usage you choose. ChatGPT Business is $20 per seat per month (annual; $25 monthly) and Claude Team $20–25 per standard seat — a 10-person team pays $200–250/month before anyone sends a message.

---

## Deploy LibreChat in Under 10 Minutes

1. Set `ADMIN_EMAIL` when deploying — it's the only required input.
2. Click **Deploy on Railway** — LibreChat builds and the databases start (~5–8 minutes).
3. Copy `ADMIN_PASSWORD` from the LibreChat service's variables and sign in at the public URL.
4. Add an `OPENROUTER_KEY` (or your own OpenAI, Anthropic or Google keys) to enable models for everyone, or let each user paste their own key in the UI.
5. Set `ALLOW_REGISTRATION` to `true` while your team signs up, then back to `false`.

No Docker Compose. No hand-made encryption keys. No reverse proxy.

---

## Common Use Cases

- **Self-hosted ChatGPT alternative** — "open source chatgpt alternative" with no per-seat pricing
- **One interface for every model** — switch between GPT, Claude, Gemini and OpenRouter models mid-conversation
- **Team AI workspace** — shared agents and presets on one private instance
- **Chat with your documents** — upload PDFs and files and ask questions with RAG
- **Private AI for sensitive data** — conversations stay in your own MongoDB, not a vendor's app
- **Pairs with n8n** — connect LibreChat agents to your automations through MCP and APIs

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `ADMIN_EMAIL` | ✅ Required | Email of the admin account created on first start. |
| `ADMIN_PASSWORD` | 🔐 Auto-generated | Admin password — copy it from the variables to sign in. |
| `OPENROUTER_KEY` | Optional | One key for chat models and file search for everyone. |
| `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_KEY` | Optional | `user_provided` lets each user enter their own key; replace with a real key to share one. |
| `CREDS_KEY`, `CREDS_IV` | 🔐 Auto-generated | Encrypt stored API keys. **Never change them after users save keys.** |
| `JWT_SECRET`, `JWT_REFRESH_SECRET` | 🔐 Auto-generated | Sign sessions; `JWT_SECRET` is shared with the RAG API. |
| `DOMAIN_CLIENT`, `DOMAIN_SERVER` | ✅ Auto-injected | Public URL. Update both when you add a custom domain. |
| `ALLOW_REGISTRATION` | Optional | `false` by default. Turn on briefly so your team can sign up. |
| `MONGO_URI`, `MEILI_*`, `RAG_API_URL` | ✅ Auto-injected | Private connections to MongoDB, Meilisearch and the RAG API. |

**Keep `CREDS_KEY` and `CREDS_IV` safe.** LibreChat doesn't re-encrypt stored keys when they change, so replacing them makes every saved user API key unreadable.

---

## LibreChat vs. Alternatives

| | LibreChat (Railway) | ChatGPT Business | Claude Team | Open WebUI (self-hosted) |
|---|---|---|---|---|
| **Monthly cost** | ~$12–20 + API usage | $20–25 per seat | $20–25 per seat | Free, you host it |
| **Self-hosted** | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
| **Per-seat pricing** | ✅ None | ❌ Per seat | ❌ Per seat | ✅ None |
| **Models from many providers** | ✅ OpenAI, Anthropic, Google, OpenRouter… | ❌ OpenAI only | ❌ Anthropic only | ✅ Ollama and OpenAI-compatible |
| **Chat with files (RAG)** | ✅ Built in | ✅ Built in | ✅ Built in | ✅ Built in |
| **Agents and tools** | ✅ Agents and MCP | ✅ Yes | ✅ Yes | ✅ Tools and functions |
| **Data stays on your infra** | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
| **License** | ✅ MIT | ❌ Proprietary | ❌ Proprietary | ⚠️ Open WebUI License (branding terms) |

---

## Dependencies for LibreChat Hosting

- Railway account — Hobby ($5/month) runs it; plan for ~1.2–1.5 GB RAM across five services.
- API keys for the models you want (OpenRouter, OpenAI, Anthropic or Google), either shared or per user.
- An OpenRouter key if you want file search (RAG).

### Deployment Dependencies

- [LibreChat GitHub](https://github.com/LibreChat-AI/LibreChat) — source and releases
- [LibreChat Docs](https://www.librechat.ai/docs) — configuration and providers
- [Meilisearch](https://www.meilisearch.com/docs) — conversation search
- [Railway Volumes Documentation](https://docs.railway.com/volumes) — persistence

### Implementation Details

LibreChat builds from the template's GitHub source and talks to `mongo:8.0`, `getmeili/meilisearch:v1.35.1`, the `librechat-rag-api-dev-lite` RAG API and `pgvector/pgvector:pg17` over the private network. MongoDB binds with IPv6 for Railway's internal network, and uploads live on the `/data` volume.

The values to protect are `CREDS_KEY` and `CREDS_IV`, which encrypt user API keys, and `JWT_SECRET`, which the RAG API also uses. `DOMAIN_CLIENT` and `DOMAIN_SERVER` must match the public URL — update both together for a custom domain.

---

## Frequently Asked Questions

**What is LibreChat and why self-host it?**
LibreChat is an open-source ChatGPT-style interface that works with many AI providers in one place. Self-hosting removes per-seat fees, lets you pick any model, and keeps conversations in your own database.

**How much does self-hosting LibreChat cost compared to ChatGPT Business?**
About $12–20/month in Railway usage plus pay-as-you-go API costs. ChatGPT Business is $20 per seat per month billed annually ($25 monthly), so 10 users cost $200–250/month on seats alone.

**Why isn't file upload or file search working in LibreChat?**
The RAG API needs `OPENROUTER_KEY` on the LibreChat service to create embeddings. Add the key and redeploy rag-api; until then, chat works but file search doesn't.

**Do I lose conversations when I redeploy?**
No. Conversations, users and agents live in MongoDB on a persistent volume, file embeddings in pgvector, and uploads on LibreChat's `/data` volume. The Meilisearch index has no volume and is rebuilt from MongoDB after a redeploy.

**Can I use Claude, Gemini or local models with LibreChat?**
Yes. LibreChat supports OpenAI, Anthropic, Google, AWS Bedrock, OpenRouter, Groq, Mistral, DeepSeek and more, plus any OpenAI-compatible endpoint through custom endpoints.

**How do users get accounts if registration is closed?**
The admin account is created from `ADMIN_EMAIL` on first start. To add your team, set `ALLOW_REGISTRATION` to `true`, let them sign up, then set it back to `false`.

---

## Why Deploy and Host LibreChat on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying LibreChat on Railway, you get a private, multi-model AI chat for your team — agents, file search and conversation search — for a flat hosting cost plus only the API usage you choose.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Möbius v0.1 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.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.

Open this page in a browser: https://railway.com/deploy/librechat-self-hosted
