Deploy LightRAG + Neo4j

Graph RAG with Neo4j and Open WebUI: chat with your documents

Deploy LightRAG + Neo4j

/var/lib/postgresql/data

Just deployed

/data

Just deployed

/app/data

Just deployed

Deploy and Host LightRAG + Neo4j on Railway

LightRAG is an open-source, graph-based RAG framework from HKU Data Science Lab and a lighter, faster alternative to Microsoft GraphRAG. Upload your documents and LightRAG uses an LLM to extract entities and relationships into a knowledge graph, then answers questions by combining graph traversal with vector search. This template stores that graph in Neo4j, keeps vectors in PostgreSQL with pgvector, and adds Open WebUI so anyone can chat with the knowledge base like ChatGPT.

About Hosting LightRAG + Neo4j

LightRAG needs four kinds of storage: key-value data, vector embeddings, document processing status and the knowledge graph itself. Its file-based defaults are meant for local testing, so this template wires production backends instead: Neo4j holds the knowledge graph, and Railway PostgreSQL holds everything else, with LightRAG enabling the pgvector extension itself on first start. Open WebUI connects to LightRAG's Ollama-compatible API and shows it as a chat model. Every password, API key and signing secret is generated at deploy time, and the services talk over Railway's private network. Neo4j and Postgres have no public domain. LightRAG normally leaves its Ollama-compatible routes open even with authentication enabled; because those routes call your LLM, this template locks them behind the API key, and Open WebUI sends that key automatically. You only provide an OpenAI API key.

Common Use Cases

  • Chatting with company documents such as wikis, policies, contracts and reports, with answers that connect facts spread across many files
  • Research and literature review with multi-hop questions across papers
  • Legal and compliance analysis that traces how parties, clauses and obligations relate across agreements
  • Customer support knowledge bases that understand how products, features and known issues connect
  • Exploring the extracted knowledge graph visually in the LightRAG Web UI or with Cypher in Neo4j
  • A private RAG backend for your own apps, queried over a REST API

Dependencies for LightRAG + Neo4j Hosting

  • An OpenAI API key, used for both the LLM (gpt-5.4-mini) and embeddings (text-embedding-3-small)
  • Optionally, any OpenAI-compatible provider instead, such as OpenRouter, Azure OpenAI or a self-hosted vLLM
  • Official images: ghcr.io/hkuds/lightrag, neo4j and ghcr.io/open-webui/open-webui, plus Railway PostgreSQL

Deployment Dependencies

Implementation Details

Services

ServiceImageRole
LightRAGghcr.io/hkuds/lightrag:v1.5.7API server and Web UI: document upload, knowledge graph explorer, query playground
Neo4jneo4j:5.26-community + APOCKnowledge graph storage for entities and relationships
PostgresRailway PostgreSQLKey-value storage, vector embeddings and document status. LightRAG enables the pgvector extension automatically on first start.
Open WebUIghcr.io/open-webui/open-webui:v0.12.4ChatGPT-style chat interface, with LightRAG as the model lightrag:latest

All images are pinned to tested versions, so an upstream release never breaks your deployment unexpectedly.

Getting started

  1. Click Deploy and enter your OpenAI API key. Neo4j downloads the APOC plugin on first boot, so the first deployment takes a couple of minutes. LightRAG may restart once or twice while it waits for Neo4j; this is expected.
  2. Open the LightRAG public URL and sign in with the user admin and the password from the LightRAG service variable ADMIN_PASSWORD.
  3. Go to Documents and upload your files (PDF, DOCX, TXT, Markdown and more). Indexing calls the LLM for every chunk, so large uploads take a while and are where most of your LLM cost goes.
  4. Open the Knowledge Graph tab to explore what was extracted, or try questions in Retrieval.
  5. Open the Open WebUI public URL right away and create your account. The first account becomes the admin, so don't leave the sign-up page unclaimed. You can disable public sign-ups afterwards in Admin Panel → Settings.
  6. Pick the lightrag:latest model and start asking questions.

Query modes

In Open WebUI, start a message with a prefix to choose how LightRAG retrieves context. Without a prefix it uses mix (knowledge graph + vector search), which is the recommended default.

PrefixWhat it does
/localFocuses on specific entities and their direct relationships
/globalUses relationship-level knowledge across the whole graph
/hybridCombines local and global retrieval
/naivePlain vector search, no graph
/contextReturns the retrieved context without generating an answer

Calling the API

curl -X POST "https:///query" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: " \
  -d '{"query": "What are the main themes in these documents?", "mode": "mix"}'

Interactive API docs are available at /docs on your LightRAG domain. The API key is in the LightRAG service variable LIGHTRAG_API_KEY, and it must be sent in the X-API-Key header (not as a Bearer token).

Adding users to the LightRAG Web UI

Edit AUTH_ACCOUNTS on the LightRAG service as comma-separated user:password pairs, for example admin:pass1,alice:pass2, then redeploy.

Using another LLM provider

Any OpenAI-compatible API works. For OpenRouter, set LLM_BINDING_HOST=https://openrouter.ai/api/v1, your OpenRouter key in LLM_BINDING_API_KEY, and a model such as google/gemini-2.5-flash in LLM_MODEL. If your provider has no embedding endpoint, keep embeddings on OpenAI by setting EMBEDDING_BINDING_API_KEY to an OpenAI key.

Changing the embedding model

The embedding dimension is fixed once the first document is indexed. To use a different model, change EMBEDDING_MODEL and EMBEDDING_DIM before uploading anything. For models above 2000 dimensions (such as text-embedding-3-large), also set POSTGRES_VECTOR_INDEX_TYPE=HNSW_HALFVEC.

Memory and scaling

Neo4j starts with a 512 MB heap and 512 MB page cache, which suits small and medium knowledge bases on the Hobby plan. For larger graphs, raise NEO4J_server_memory_heap_max__size and NEO4J_server_memory_pagecache_size on the Neo4j service. Your data lives on Railway volumes (Neo4j /data, Postgres, LightRAG /app/data, Open WebUI /app/backend/data) and persists across redeploys.

Why Deploy LightRAG + Neo4j 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 LightRAG + Neo4j 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.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
NEW
Weaviate
Vector database with hybrid search and an API key-protected API

zer0person
1
View Template
NEW
Möbius v0.1 Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

bento
1