---
title: "Deploy RAGFlow"
description: "Turns your documents into a searchable, citable knowledge base"
category: "AI/ML"
url: https://railway.com/deploy/ragflow-ai
---

# Deploy RAGFlow

Turns your documents into a searchable, citable knowledge base

**[Deploy RAGFlow on Railway](https://railway.com/template/ragflow-ai)**

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

## Template content

### ragflow https://raw.githubusercontent.com/infiniflow/ragflow/v0.27.1/web/public/logo.svg

- **Source:** https://github.com/gridalpha/ragflow-railway
- **Public domain:** Yes

### Redis https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/redis.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

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

- **Source:** https://github.com/gridalpha/ragflow-elasticsearch-railway

### MySQL https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/mysql.svg

- **Image:** mysql:9.4
- **Start command:** `docker-entrypoint.sh mysqld --innodb-use-native-aio=0 --disable-log-bin --performance_schema=0 --innodb-buffer-pool-size=1G`

### tei https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/hugging-face.svg

- **Image:** ghcr.io/huggingface/text-embeddings-inference:cpu-1.8
- **Health check:** /health

## Buckets

- **ragflow-storage**

## Documentation

![RAGFlow logo](https://raw.githubusercontent.com/infiniflow/ragflow/main/web/src/assets/logo-with-text.svg)

# Deploy and Host RAGFlow on Railway

RAGFlow is an open-source retrieval-augmented generation engine built around deep document understanding. Instead of splitting a PDF on character counts, it runs layout recognition and OCR over the page first, so tables stay tables, headings stay attached to the text under them, and a scanned invoice or a 200-page manual produces chunks a language model can cite. Teams use it to turn contracts, research libraries, support archives and internal wikis into a knowledge base, then attach a chat assistant or an agent that answers with citations back to the source page.

This template lets you self-host RAGFlow on Railway with every backing service already wired together. The RAGFlow container serves the web interface and API and runs the document task executor. Elasticsearch stores chunks and serves hybrid keyword-plus-vector retrieval. A private text-embeddings-inference service loads `BAAI/bge-small-en-v1.5`, so the deployment produces real embeddings with no external API key. MySQL holds datasets, documents, users and agents, Redis carries the parsing queue, and a Railway bucket keeps the uploaded files.

![Diagram of the RAGFlow, Elasticsearch, embedding, MySQL and Redis services on Railway](https://res.cloudinary.com/rroe4rtk/image/upload/v1788045582/ragflow-architecture.png)

## Getting Started with RAGFlow on Railway

Open the RAGFlow service's public URL once the deploy is live. Sign in with the email you set in `DEFAULT_SUPERUSER_EMAIL` and the password Railway generated for `DEFAULT_SUPERUSER_PASSWORD`, readable on that service's Variables tab. Registration is off, so this account is the only way in until you invite teammates from the Team page. Open the avatar menu and check **Model providers → Set default models**: the embedding model already reads `BAAI/bge-small-en-v1.5`, supplied by the bundled service. Add a chat provider key here too — OpenAI, DeepSeek, Anthropic, OpenRouter or any OpenAI-compatible endpoint — since RAGFlow asks for a language model before it opens the dataset dialog.

Now go to **Dataset**, create one, and drag in a PDF or a few text files. Each row shows a Chunks count once parsing finishes; if it stays at zero, open Logs on that dataset. Then click **Retrieval testing**, ask a question your documents answer, and press Run. Scored results with hybrid, term and vector similarity mean the path is healthy end to end: object storage, parser, embedding service and Elasticsearch.

![RAGFlow dataset listing three parsed text files with chunk counts](https://res.cloudinary.com/rroe4rtk/image/upload/v1788045584/ragflow-dataset-files.png)

![Document preview beside the chunks RAGFlow embedded from it](https://res.cloudinary.com/rroe4rtk/image/upload/v1788045586/ragflow-chunks.png)

![Retrieval test scoring five chunks by hybrid and vector similarity](https://res.cloudinary.com/rroe4rtk/image/upload/v1788045587/ragflow-retrieval-testing.png)

## About Hosting RAGFlow

RAGFlow is a complete RAG platform rather than a library: it ships the ingestion pipeline, the chunk store, a retrieval tuner, a chat builder and a visual agent canvas, so a knowledge assistant needs no orchestration code. Self-hosting matters because the documents are the sensitive part — they stay in your own infrastructure, and only the prompt leaves.

Key capabilities:

- Layout-aware parsing of PDF, DOCX, PPTX, XLSX, images, HTML and Markdown, with OCR and table recognition
- Chunk templates per document type — paper, book, laws, manual, resume, table, Q&A
- Hybrid BM25-plus-vector retrieval, with optional reranking and cross-language search
- Grounded answers citing the exact chunk and page
- A visual agent builder, an MCP server, and a REST API with Python and JavaScript SDKs

The template splits the work across five services. **RAGFlow** serves the UI and API through nginx and runs the task executor that parses documents. **Elasticsearch** holds every chunk with its vector and answers retrieval queries. **tei** runs Hugging Face's text-embeddings-inference server, keeping embedding local and free. **MySQL** stores metadata and **Redis** queues parsing jobs. The bucket holds original files, streamed back through the app rather than exposed publicly.

## Why Deploy RAGFlow on Railway

Railway removes the infrastructure work this stack needs:

- Elasticsearch, MySQL, Redis, embeddings and object storage provisioned and connected in one deploy
- Private networking, with only the web interface exposed
- Persistent volumes for the search index and the model cache
- Free HTTPS on a generated domain, plus per-service metrics and vertical scaling

## Common Use Cases

- An internal knowledge assistant over policies, runbooks and onboarding material, answering with citations staff can verify
- Contract and compliance review, where layout-aware parsing keeps clause numbering and tables intact across scanned pages
- Support deflection grounded in product manuals and past tickets
- A private research library answering cross-document questions without sending files to a third party

## Dependencies for RAGFlow

- **RAGFlow** — [gridalpha/ragflow-railway](https://github.com/gridalpha/ragflow-railway), built on `infiniflow/ragflow:v0.27.1`
- **Elasticsearch** — [gridalpha/ragflow-elasticsearch-railway](https://github.com/gridalpha/ragflow-elasticsearch-railway), built on `elasticsearch:8.11.3`
- **Embeddings** — `ghcr.io/huggingface/text-embeddings-inference:cpu-1.8`
- **MySQL 9.4**, **Redis 8.2** and a Railway object storage bucket — managed by Railway

### Environment Variables Reference

| Variable | Service | Purpose |
|---|---|---|
| `DEFAULT_SUPERUSER_EMAIL` | RAGFlow | Email for the administrator created on first boot |
| `DEFAULT_SUPERUSER_PASSWORD` | RAGFlow | That administrator's password; change it after signing in |
| `REGISTER_ENABLED` | RAGFlow | `1` opens self-service signup, `0` keeps the instance closed |
| `TEI_MODEL` | RAGFlow | Embedding model; must match `MODEL_ID` on the tei service |
| `ES_JAVA_OPTS` | elasticsearch | JVM heap for the search index |

### Deployment Dependencies

- Source: [github.com/infiniflow/ragflow](https://github.com/infiniflow/ragflow)
- Docs: [ragflow.io/docs](https://ragflow.io/docs)
- Embeddings: [text-embeddings-inference](https://github.com/huggingface/text-embeddings-inference)

## Hardware Requirements for Self-Hosting RAGFlow

| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 4 vCPU across all services | 8 vCPU or more |
| RAM | 8 GB total | 16 GB, 4 GB for Elasticsearch |
| Storage | 5 GB index, 5 GB model cache | 20 GB+ as the corpus grows |
| Runtime | Docker | Docker |

Parsing is the CPU-hungry part: OCR and layout recognition on a large scanned PDF saturates a core for minutes, so raise the RAGFlow service first. Elasticsearch wants headroom above its heap; `-Xms2g -Xmx2g` suits an 8 GB container.

## Self-Hosting RAGFlow with Docker

Upstream ships a Compose stack. Clone the repository and start it with these shell commands:

```
git clone https://github.com/infiniflow/ragflow.git
cd ragflow/docker
docker compose -f docker-compose.yml up -d
```

Every service is configured through `docker/.env`. To point RAGFlow at external backing services instead of the bundled ones, set these there before the first start:

```
DOC_ENGINE=elasticsearch
ES_HOST=elasticsearch.internal
ELASTIC_PASSWORD=your-elastic-password
MYSQL_HOST=mysql.internal
MYSQL_PASSWORD=your-mysql-password
REDIS_HOST=redis.internal
```

Storage is chosen with `STORAGE_IMPL`, which accepts `MINIO`, `AWS_S3`, `OSS`, `GCS` and the Azure variants; its settings live in `docker/service_conf.yaml.template`. This template already uses the S3 path against a managed bucket.

## How Much Does RAGFlow Cost to Self-Host?

RAGFlow is free and open source under the Apache 2.0 licence, with no seat limits and no paid edition of the server. Self-hosting on Railway costs infrastructure only — roughly a small application plus a search cluster. The one variable expense is the language model, billed by whichever provider key you configure; embeddings are generated locally and cost nothing beyond CPU.

## FAQ

**What is RAGFlow?**

RAGFlow is an open-source retrieval-augmented generation engine from InfiniFlow. It ingests documents, understands their layout, chunks and embeds them, and serves hybrid retrieval with citations.

**What does this Railway template deploy?**

Five services — RAGFlow, Elasticsearch as the document engine, a text-embeddings-inference server, MySQL and Redis — plus a bucket for uploaded files.

**Do I need an OpenAI API key to run self-hosted RAGFlow?**

Not to ingest documents: parsing, chunking, embedding and retrieval testing work out of the box, because embeddings come from the bundled service. Chat and agents call a language model, so those need a provider key.

**Why does RAGFlow need Elasticsearch, MySQL, Redis and object storage?**

Each holds different state. Elasticsearch stores chunks and vectors and does the ranking, MySQL stores datasets, documents, users and agents, Redis queues parsing jobs, and the bucket keeps the originals.

**How do I change the embedding model in self-hosted RAGFlow?**

Set `MODEL_ID` on the embedding service and `TEI_MODEL` on RAGFlow to the same value, then redeploy both. `BAAI/bge-m3` and `Qwen/Qwen3-Embedding-0.6B` are the other built-ins and need much more memory. Datasets parsed under the old model must be re-parsed.

**How do I speed up document parsing on Railway?**

Raise the RAGFlow service's CPU and memory first, since parsing runs there. For bulk ingestion, add a second service from the same repository with the start command `/ragflow/entrypoint-railway.sh --disable-webserver --workers=2`; it takes jobs off the same Redis queue.


## 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/ragflow-ai
