---
title: "Deploy LibreChat | ChatGPT Alternative, Files + Search That Persist"
description: "Self-hosted ChatGPT alternative: file RAG with no API key, uploads persist"
category: "AI/ML"
url: https://railway.com/deploy/librechat-or-chatgpt-alternative-files-s
---

# Deploy LibreChat | ChatGPT Alternative, Files + Search That Persist

Self-hosted ChatGPT alternative: file RAG with no API key, uploads persist

**[Deploy LibreChat | ChatGPT Alternative, Files + Search That Persist on Railway](https://railway.com/template/librechat-or-chatgpt-alternative-files-s)**

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

## Template content

### pgvector

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

### mongo

- **Image:** mongo:8.3.7-noble
- **Start command:** `/bin/sh -c 'export MONGO_INITDB_ROOT_USERNAME=librechat && exec docker-entrypoint.sh mongod --ipv6 --bind_ip ::,0.0.0.0'`

### rag

- **Image:** ghcr.io/bon5co/librechat-rag-railway:latest
- **Start command:** `python /usr/local/bin/serve.py`

### librechat

- **Image:** ghcr.io/bon5co/librechat-railway:latest
- **Health check:** /health
- **Public domain:** Yes

### meilisearch

- **Image:** getmeili/meilisearch:v1.51.0
- **Start command:** `/bin/sh -c 'export MEILI_ENV=production MEILI_HTTP_ADDR="[::]:7700" MEILI_NO_ANALYTICS=true MEILI_DB_PATH=/meili_data/data.ms && exec /bin/meilisearch'`

## Documentation

# Deploy and Host LibreChat on Railway

LibreChat is the open-source, self-hosted ChatGPT alternative: one interface across OpenAI,
Anthropic, Google, DeepSeek, xAI, Groq, Mistral, OpenRouter and any OpenAI-compatible endpoint,
with multi-user accounts, conversation search, agents, and chat-with-your-files. This template
deploys the pinned v0.8.7 release with MongoDB, Meilisearch, pgvector and a RAG API — five
services wired over the private network, with file search working on first boot and no API key of
any kind required to deploy.

## About Hosting LibreChat

LibreChat is not a single container. Conversations, users, presets and agent definitions live in
MongoDB. Message search is served by Meilisearch, which maintains its own index. Chatting with an
uploaded document needs a RAG API and a pgvector database to hold the embeddings. Uploaded files
and images produced by tools and agents are written to the application's own filesystem, in two
different directories.

Three details decide whether a LibreChat deployment on Railway actually works, and none of them
are visible on a deploy form:

**Every service has to be bound and wired for the private network.** Meilisearch binds loopback
unless `MEILI_HTTP_ADDR` says otherwise, which is a common cause of a deployment that starts fine
and never returns a search result. Here Mongo and Meilisearch listen on both address families, the
RAG API runs on a dual-stack socket, and the app's connection strings are generated from the
private domains — so nothing depends on which address family gets resolved.

**The application service needs a volume too, not just the datastores.** LibreChat writes user
uploads to `/app/uploads` and tool- or agent-generated images to `/app/client/public/images`.
Without a volume both are lost on every redeploy, while MongoDB keeps the message rows that point
at them. This template mounts a volume at `/app/uploads` and links the images directory into it,
so both survive.

**Embeddings normally cost an extra API key.** The RAG API image published for lightweight
deployments has no local embedding support, so file search stays dark until you supply an OpenAI
key. This template runs `sentence-transformers/all-MiniLM-L6-v2` on CPU, baked into the image at
build time, so document chat works out of the box, offline, with no third-party key and no
per-boot model download. Moving to a hosted embeddings provider later is a two-variable change.

Every image is pinned to an exact release rather than a rolling `latest` or `-dev` tag, so two
people deploying this a month apart get the same application. MongoDB and Meilisearch run
authenticated, and neither datastore, nor pgvector, nor the RAG API is given a public domain —
only the chat UI is reachable from the internet.

## Why Deploy 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 are one step closer to supporting a complete full-stack
application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Chat with your files on first boot** — RAG API and pgvector included, embeddings run locally
  on CPU, no OpenAI key needed to make it work.
- **Nothing to fill in** — the deploy form is empty. Every secret is generated per deploy at the
  exact length LibreChat requires, and every service-to-service URL is wired for you.
- **Uploads and generated images persist** — a volume on the app service, not only on the
  databases.
- **Correct private networking** — Mongo, Meilisearch and the RAG API all listen on both address
  families, and none of them is exposed to the internet.
- **Pinned, reproducible versions** — LibreChat v0.8.7, MongoDB 8.3, Meilisearch v1.51,
  pgvector 0.8.6/pg17. No rolling dev tags.
- **Bring your own model keys** — each user pastes their own provider key into the UI, encrypted
  before it reaches the database, and pays API rates instead of a per-seat subscription.

## Common Use Cases

- **Team ChatGPT replacement** — one self-hosted interface with accounts, shared presets and
  history, at API prices instead of per-seat pricing.
- **Private document chat** — upload contracts, papers or manuals and query them, with the
  embeddings computed inside your own deployment.
- **Multi-provider comparison** — run the same prompt against OpenAI, Anthropic, Google, DeepSeek
  and OpenRouter models side by side in one conversation view.

## Dependencies for LibreChat Hosting

Everything LibreChat needs is included in this template — there is nothing to provision
separately:

- MongoDB 8.3, authenticated, on a volume at `/data/db`.
- Meilisearch v1.51 for conversation search, behind a generated master key, on a volume at
  `/meili_data`.
- pgvector 0.8.6 (pg17) for document embeddings, on a volume at `/var/lib/postgresql`.
- A RAG API service with local CPU embeddings.

A model provider API key (OpenAI, Anthropic, Google, or any OpenAI-compatible endpoint) is added
per user from the UI after deploy. It is not required to deploy, and it is not required for file
search.

### Deployment Dependencies

- [LibreChat](https://github.com/danny-avila/LibreChat) — upstream project (MIT)
- [LibreChat documentation](https://www.librechat.ai/docs) — providers, agents and configuration
- [rag_api](https://github.com/danny-avila/rag_api) — the RAG service upstream (MIT)
- [bon5co/librechat-railway](https://github.com/bon5co/librechat-railway) — the app image this
  template deploys, and why each default is baked in
- [bon5co/librechat-rag-railway](https://github.com/bon5co/librechat-rag-railway) — the RAG image,
  with CPU-only torch and the embedding model baked in

### Implementation Details

| Service | Image | Volume | Public |
| --- | --- | --- | --- |
| `librechat` | `ghcr.io/bon5co/librechat-railway:latest` (LibreChat v0.8.7) | `/app/uploads` | yes |
| `rag` | `ghcr.io/bon5co/librechat-rag-railway:latest` | — | no |
| `mongo` | `mongo:8.3.7-noble` | `/data/db` | no |
| `meilisearch` | `getmeili/meilisearch:v1.51.0` | `/meili_data` | no |
| `pgvector` | `pgvector/pgvector:0.8.6-pg17` | `/var/lib/postgresql` | no |

After deploy, open the public domain and register the first account. Registration is open so that
first account can be created — set `ALLOW_REGISTRATION=false` on the `librechat` service
afterwards if the instance should not accept public signups.

Then add a model provider key from the UI. Keys are encrypted with the per-deploy
`CREDS_KEY`/`CREDS_IV` before they are stored, so do not rotate those two after users have saved
keys.

Confirm the stack is healthy:

```bash
curl https:///health     # OK
```

Conversation search indexes in the background, so new conversations become searchable shortly
after they are created. Document chat works immediately: upload a file in a conversation, or
attach one to an agent, and the embeddings are computed by the `rag` service.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/librechat-or-chatgpt-alternative-files-s
