---
title: "Deploy LightRAG"
description: "LightRAG Pro Stack: Light RAG, PostgreSQL, pgvector, GraphRAG and auth."
category: "AI/ML"
url: https://railway.com/deploy/lightrag-1
---

# Deploy LightRAG

LightRAG Pro Stack: Light RAG, PostgreSQL, pgvector, GraphRAG and auth.

**[Deploy LightRAG on Railway](https://railway.com/template/lightrag-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/lightrag-1/manifest.json

- **Creator:** Xav's Projects
- **Category:** AI/ML
- **Total deploys:** 3

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### LightRAG https://raw.githubusercontent.com/HKUDS/LightRAG/main/assets/logo.png

- **Image:** ghcr.io/hkuds/lightrag@sha256:5bdbd524931b011df246fe20888d110cef691e6804c12cde636a2b746d7de27e
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host LightRAG on Railway

LightRAG (Light RAG) combines a knowledge graph with vector search so you can ask questions about your own documents. This **LightRAG Pro Stack** includes the Web UI, authenticated API, PostgreSQL and pgvector, with persistent storage already connected.

## About Hosting LightRAG

This template runs **LightRAG v1.5.7** and **Railway PostgreSQL 18 with pgvector** using the official LightRAG image pinned by digest and Railway’s native PostgreSQL SSL image. PostgreSQL stores the documents, processing status, embeddings, entities and relationships. Native `PGTableGraphStorage` keeps the knowledge graph in PostgreSQL as well.

There are two services and two persistent volumes. The PostgreSQL service includes Railway’s standard `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE` and `DATABASE_URL` variables for the Data and Connect panels. The database is reachable over Railway's private network; only LightRAG receives a public HTTPS domain. An administrator password, API key and token signing secret are generated separately for every deployment.

### Get started

1. Enter your **OpenAI API key** in `LLM_BINDING_API_KEY` and deploy. This is the only required input.
2. Wait for both services to start, then open the LightRAG public URL.
3. Sign in with username **admin** and the generated **ADMIN_PASSWORD** from the LightRAG service variables.
4. Upload a text document or a PDF containing selectable text. Wait until its status is **Processed**.
5. Open Retrieval and ask a question about the document. You can also explore its entities and relationships in the graph view.

You can change `ADMIN_USERNAME` and `ADMIN_PASSWORD` in Railway variables, then redeploy LightRAG. The API key is a separate credential; it is not your administrator password or your model provider key.

## Common Use Cases

- Build a private knowledge base for an internal team or research project.
- Search documents using vector retrieval and GraphRAG, including local, global, hybrid, naive and mix query modes.
- Connect a persistent document retrieval API to an automation or chat application.
- Use the authenticated Ollama-compatible routes with clients that support a custom API-key header.

## Dependencies for LightRAG Hosting

- LightRAG API server and bundled Web UI, version 1.5.7.
- PostgreSQL 18 with the pgvector extension.
- An OpenAI account with API access, or another compatible model provider configured in the variables below.

### Deployment Dependencies

- [LightRAG source](https://github.com/HKUDS/LightRAG)
- [LightRAG API server documentation](https://github.com/HKUDS/LightRAG/blob/v1.5.7/docs/LightRAG-API-Server.md)
- [LightRAG Docker deployment guide](https://github.com/HKUDS/LightRAG/blob/v1.5.7/docs/DockerDeployment.md)
- [pgvector](https://github.com/pgvector/pgvector)

## Configuration

| Variable | Default or purpose |
| --- | --- |
| `LLM_BINDING_API_KEY` | Your model provider key; required. |
| `LLM_MODEL` | `gpt-4o-mini` |
| `LLM_BINDING_HOST` | `https://api.openai.com/v1` |
| `EMBEDDING_MODEL` | `text-embedding-3-small` |
| `EMBEDDING_DIM` | `1536` |
| `EMBEDDING_BINDING_API_KEY` | References `LLM_BINDING_API_KEY` by default. |
| `EMBEDDING_BINDING_HOST` | `https://api.openai.com/v1` |
| `ADMIN_USERNAME` | `admin` |
| `ADMIN_PASSWORD` | Generated for your deployment. |
| `LIGHTRAG_API_KEY` | Generated key for authenticated API clients. |
| `TOKEN_SECRET` | Generated token signing secret; keep it stable across restarts. |

For a different provider, update the LLM binding, API host and model, plus the embedding binding, host, model, dimension and key as needed. Chat and embedding providers can be configured separately. Choose an embedding model before importing data; changing its model or dimension later requires rebuilding the affected indexes.

Model inference uses the configured provider. Provider charges are separate from Railway resource usage. Native document parsing is enabled; scanned PDF OCR and image understanding require additional configuration and are not included in this default setup.

## Persistent Storage and Restarts

| Service | Volume mount | Stored data |
| --- | --- | --- |
| LightRAG | `/app/data` | Uploaded files, working files, prompts and logs. |
| Postgres | `/var/lib/postgresql/data` | Database cluster, including all four LightRAG storage backends. |

The PostgreSQL data directory is `/var/lib/postgresql/data/pgdata`. LightRAG uses `PGKVStorage`, `PGVectorStorage`, `PGTableGraphStorage` and `PGDocStatusStorage`. It creates the required tables and pgvector extension automatically on the included database.

Restarting or redeploying these services preserves their attached volumes. Deleting a volume deletes its contents. Back up both PostgreSQL and the uploaded files before major upgrades. Keep the database on PostgreSQL 18 unless you carry out a database migration. The pinned images make upgrades explicit rather than changing the application on every redeploy.

The public `/health` endpoint is used for Railway health checks. Document, query and Ollama-compatible API routes require authentication. Deployment connection retries allow LightRAG to wait for PostgreSQL during startup.

## API and Open WebUI Connection

Use the LightRAG public HTTPS URL as the base URL. Send `X-API-Key: YOUR_LIGHTRAG_API_KEY` for API calls, or use the bearer token returned by `/login`.

LightRAG also provides Ollama-compatible endpoints under `/api`, including `/api/tags` and `/api/chat`. In an Open WebUI connection that supports custom headers, use the LightRAG URL as an Ollama endpoint and add the `X-API-Key` header. A raw API key sent as a bearer token does not replace this header. The generated API key is available in the LightRAG service variables.

## Why Deploy LightRAG on Railway?

Railway connects the application and database over private networking, provides HTTPS for the Web UI and attaches persistent volumes. This template combines those pieces with generated credentials and PostgreSQL graph storage, so the initial setup only asks for your model provider key.

LightRAG is distributed under the MIT license. Review the upstream documentation when configuring additional providers, parsers or production backup policies.


## 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/lightrag-1
