---
title: "Deploy MaxKB RAG Agents + Postgres"
description: "MaxKB RAG and agent platform with pgvector Postgres and Redis"
category: "AI/ML"
url: https://railway.com/deploy/maxkb-rag-agents-postgres
---

# Deploy MaxKB RAG Agents + Postgres

MaxKB RAG and agent platform with pgvector Postgres and Redis

**[Deploy MaxKB RAG Agents + Postgres on Railway](https://railway.com/template/maxkb-rag-agents-postgres)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/maxkb-rag-agents-postgres/manifest.json

- **Creator:** Protemplate
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### Redis https://avatars.githubusercontent.com/u/1529926?v=4

- **Image:** redis:7.4.6-alpine
- **Start command:** `sh -c 'exec docker-entrypoint.sh redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes --dir /data --bind :: 0.0.0.0'`

### Postgres https://avatars.githubusercontent.com/u/177543?v=4

- **Image:** pgvector/pgvector:0.8.1-pg17
- **Start command:** `docker-entrypoint.sh postgres -c "listen_addresses=*" -c max_connections=400 -c jit=off`

### MaxKB https://raw.githubusercontent.com/1Panel-dev/MaxKB/v2/ui/src/assets/logo/logo.png

- **Image:** 1panel/maxkb:v2.10.8-lts
- **Start command:** `bash -c 'i=0; until PGPASSWORD="$MAXKB_DB_PASSWORD" psql -h "$MAXKB_DB_HOST" -p "$MAXKB_DB_PORT" -U "$MAXKB_DB_USER" -d "$MAXKB_DB_NAME" -v ON_ERROR_STOP=1 -qc "CREATE EXTENSION IF NOT EXISTS vector"; do i=$((i+1)); if [ "$i" -ge 60 ]; then echo "maxkb: Postgres not reachable after 5 minutes"; exit 1; fi; echo "maxkb: waiting for Postgres ($i/60)"; sleep 5; done; echo "maxkb: pgvector ready, starting MaxKB"; exec /usr/bin/start-maxkb.sh'`
- **Health check:** /admin/api/profile
- **Public domain:** Yes

## Documentation

# Deploy and Host MaxKB on Railway

MaxKB is an open source platform for building enterprise knowledge base assistants and AI agents. Upload documents or crawl websites into a knowledge base, and MaxKB splits, embeds and indexes them for retrieval augmented generation (RAG). Build chat assistants and multi step agent workflows with a visual editor, call tools and MCP servers, and connect any major LLM: OpenAI, Anthropic, DeepSeek, Qwen, Gemini, Ollama and more.

## About Hosting MaxKB

The upstream image bundles PostgreSQL and Redis inside one container. This template runs them as separate Railway services instead, which the image supports natively: when `MAXKB_DB_HOST` and `MAXKB_REDIS_HOST` point elsewhere, the bundled servers stay off. You get three services: MaxKB (`1panel/maxkb:v2.10.8-lts`) on a public domain, PostgreSQL 17 with pgvector (vectors, data and uploaded files), and Redis (cache, login sessions, task queue). Each has its own volume.

The admin account is protected from the first boot. Upstream ships a public default password (`MaxKB@123..`); this template generates a random initial password in `MAXKB_DEFAULT_PASSWORD` instead, so a fresh deploy cannot be claimed by someone who finds the URL first. The start command waits for Postgres, enables the `vector` extension, and starts MaxKB without the upstream 180 second boot deadline that kills slow first boots.

## Common Use Cases

- **Internal knowledge assistant**: answer questions from company docs, wikis and websites with citations
- **Customer support bot**: embed a chat widget on your site, backed by your product docs
- **Agent workflows**: visual flows with branching, tools, MCP servers and custom Python functions
- **Model playground**: compare providers and local models behind one UI

## Dependencies for MaxKB Hosting

- **PostgreSQL 17 + pgvector** (included)
- **Redis** (included)
- **An LLM provider key**: optional at boot, added in the UI under Models
- **Hobby plan or higher**: MaxKB runs a web server, a local embedding model server and a task worker in one container; upstream recommends 8 GB RAM. Trial and Free memory limits are too small

### Deployment Dependencies

- [MaxKB GitHub repository](https://github.com/1Panel-dev/MaxKB)
- [MaxKB installation docs](https://github.com/1Panel-dev/MaxKB-docs/blob/main/docs/installation/online_installtion.md)
- [pgvector](https://github.com/pgvector/pgvector)

### Implementation Details

First steps after deploy:

1. Wait for the MaxKB service to turn healthy (the first boot pulls a 1.2 GB image and runs database migrations; allow 5 to 10 minutes).
2. Open the MaxKB domain. You land on `/admin`.
3. Log in as `admin` with the value of `MAXKB_DEFAULT_PASSWORD` from the MaxKB service variables, then change the password when prompted.
4. Add a model under Models (for example an OpenAI key), create a knowledge base, upload documents, and create an application.

Key variables on the MaxKB service:

```env
PORT=8080
MAXKB_DEFAULT_PASSWORD=MaxKB1!   # initial admin password, read once on first boot
MAXKB_SECRET_KEY=                 # signs login tokens
MAXKB_DB_HOST=${{Postgres.RAILWAY_PRIVATE_DOMAIN}}
MAXKB_REDIS_HOST=${{Redis.RAILWAY_PRIVATE_DOMAIN}}
MAXKB_CORE_WORKER=1                          # raise to 2 or 3 on bigger plans
```

`MAXKB_DEFAULT_PASSWORD` only seeds the admin account on the very first boot. Changing it later does not change the password; use the UI for that. The bundled embedding model is tuned for Chinese text; for English knowledge bases add an embedding model from your provider. Back up the Postgres service with `pg_dump` (uploaded files live in Postgres large objects, which `pg_dump` includes by default).

## Why Deploy MaxKB 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 MaxKB 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.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/maxkb-rag-agents-postgres
