Deploy LibreChat | Open Source ChatGPT Alternative
5-service LibreChat with search and RAG. ~1.5 GB RAM, about $25/month
Just deployed
MongoDB
Just deployed
/data/db
Just deployed
/var/lib/postgresql
Meilisearch
Just deployed
/meili_data
LibreChat
Just deployed
/data
Deploy and Host LibreChat on Railway
LibreChat is an open-source chat interface for every major model provider at once — OpenAI, Anthropic, Google, and two dozen more — with conversations, agents, file search and full-text history in one place. This template deploys the whole stack, configured and working.
About Hosting LibreChat
Five services, all from official upstream images:
- LibreChat — the web interface and API. Public domain, healthcheck, and a volume for uploads and generated images.
- MongoDB — conversations, messages, accounts and agents, on a volume.
- Meilisearch — full-text search across your conversation history, on a volume.
- RAG — the file-search sidecar that reads uploaded documents and answers from them.
- VectorDB — PostgreSQL with pgvector, holding the document embeddings, on a volume.
All 106 variables are filled in and described on the deploy screen. There is nothing you have to type to get a working deployment; sign in and it works. Adding your own model provider key is one variable.
Four things this template does that are worth knowing about:
File search actually reaches the RAG service. That sidecar is a Python server, and Python servers bind IPv4 by default while Railway's private network is IPv6 — so left alone it is simply unreachable from the chat container, and file search fails without an obvious reason. Here it binds :: and the two talk over the private network, which the deploy log confirms in as many words: RAG API is running and reachable. The alternative other deployments settle on is giving the RAG service a public domain, which puts your document store on the open internet.
Uploads and generated images survive a deploy. LibreChat writes avatars, uploaded files and generated images to disk. Without a volume they are gone after the next restart — the database still lists them, and every one of them 404s. The app container has a volume here, with both directories on it, and it is verified: upload, redeploy, the file is still byte-identical.
It pins released versions. The image is librechat:v0.8.7, the newest release. That is a different image from the librechat-dev:latest that upstream's compose file and the existing deployments use — dev is built from the main branch and latest moves under you. Meilisearch is on the version upstream currently pins, twenty-four minor releases ahead of what the other templates ship, and Meilisearch changes its on-disk index format between minors.
Boot logs stay readable. LibreChat prints its whole resolved configuration at info level on every start, and the bundled model catalogue makes that about 114 KB — enough to blow through Railway's per-deployment log limit and drop the one line that explains a failed boot. The console level is not configurable, so this template uses the structured log transport, which is the one that truncates. A restart now costs about forty log lines instead of six hundred.
Common Use Cases
- One interface for every provider: switch between GPT, Claude, Gemini, Llama and the rest inside a single conversation, paying each provider directly instead of a subscription per tool.
- A private team assistant: your own domain, your own accounts, your own database — no conversation leaves your deployment except to the model provider you chose.
- Chatting with your documents: upload PDFs, spreadsheets and text, and have answers grounded in them. Add an OpenAI key to the RAG service to turn it on.
- Agents and tools: build assistants with instructions, tools and file collections, and share them with the other people on your deployment.
Dependencies for LibreChat Hosting
Deployment Dependencies
- LibreChat — the upstream project and its official release image
- rag_api — the file-search sidecar, versioned separately
- MongoDB for conversations and accounts, Meilisearch for search, PostgreSQL with pgvector for embeddings
Implementation Details
- The first account to register becomes the administrator. Registration is open so you can create it; turn
ALLOW_REGISTRATIONoff once you have, because the domain is public. - Model keys default to
user_provided— each person enters their own in the interface. Put a real key in the matching variable instead and the whole deployment uses it. - File search needs one key of its own.
RAG_OPENAI_API_KEYon the RAG service starts as a placeholder rather than an empty value, because an empty key crashes that container in a loop instead of merely disabling the feature. Replace it and uploads become searchable. CREDS_KEYandCREDS_IVencrypt the keys people paste in. They are generated for you at the correct lengths. Changing either one makes every stored key unreadable, and nothing validates them at startup — a wrong value surfaces later as an unrelated-looking error.- Ban rules are on, and they are strict. A request with no browser user-agent scores an instant ban, and the ban lives in MongoDB, so a restart will not clear it. Set
NON_BROWSER_VIOLATION_SCOREto 0 before driving the REST API from a script. - The model and endpoint catalogue is fetched from LibreChat's own repository and regenerated daily, which is why
CONFIG_PATHpoints at a branch: pinning it would freeze the model lists on the day you deployed. Point it at your own file to take control. - Nothing but the app has a public address. Mongo, Meilisearch, pgvector and the RAG service are reachable only from inside the project.
Resource Usage and Cost
Five services idle at roughly 1.2–2 GB of RAM, plus 7 GB of volume — about $20–35/month. The chat container is the bulk of it; usage on top of that is mostly what you pay your model provider, not Railway.
Why Deploy LibreChat on Railway?
LibreChat is a five-container application with three different databases, and the interesting failures are all in the wiring between them: the search index, the vector store, the file sidecar. Railway gives it a private network, a volume per stateful service, a domain with TLS, and one deploy screen where every one of those connections is already filled in.
The alternative is a compose file on a VM, where the same wiring is yours to get right — starting with the one that has no error message: the file service that answers on the wrong address family and simply never replies.
Template Content
