---
title: "Deploy LobeHub Server + Postgres"
description: "LobeHub 2 server mode: AI chat and agents with Postgres, Redis and S3"
category: "AI/ML"
url: https://railway.com/deploy/lobehub-server-postgres
---

# Deploy LobeHub Server + Postgres

LobeHub 2 server mode: AI chat and agents with Postgres, Redis and S3

**[Deploy LobeHub Server + Postgres on Railway](https://railway.com/template/lobehub-server-postgres)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/lobehub-server-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-alpine
- **Start command:** `sh -c 'docker-entrypoint.sh redis-server --requirepass "$REDIS_PASSWORD" --save 60 1 --appendonly yes --dir /data --bind :: 0.0.0.0'`

### LobeHub https://raw.githubusercontent.com/lobehub/lobehub/v2.2.17/public/apple-touch-icon.png

- **Image:** lobehub/lobehub:2.2.17
- **Start command:** `sh -c 'if [ -z "$JWKS_KEY" ]; then echo "JWKS_KEY not set; generating an ephemeral RS256 key for this deployment (set JWKS_KEY to keep OIDC/desktop sign-ins across redeploys)"; export JWKS_KEY="$(echo Y29uc3QgYz1yZXF1aXJlKCdjcnlwdG8nKTtjb25zdCB7cHJpdmF0ZUtleX09Yy5nZW5lcmF0ZUtleVBhaXJTeW5jKCdyc2EnLHttb2R1bHVzTGVuZ3RoOjIwNDh9KTtjb25zdCBqPXByaXZhdGVLZXkuZXhwb3J0KHtmb3JtYXQ6J2p3ayd9KTtqLnVzZT0nc2lnJztqLmFsZz0nUlMyNTYnO2oua2lkPWMucmFuZG9tQnl0ZXMoOCkudG9TdHJpbmcoJ2hleCcpO3Byb2Nlc3Muc3Rkb3V0LndyaXRlKEpTT04uc3RyaW5naWZ5KHtrZXlzOltqXX0pKQo= | /bin/base64 -d | /bin/node)"; fi; exec /bin/node /app/startServer.js'`
- **Health check:** /api/version
- **Public domain:** Yes

### RustFS https://avatars.githubusercontent.com/u/151849438?v=4

- **Image:** rustfs/rustfs:1.0.0-rc.6
- **Start command:** `sh -c '( until curl -sf http://127.0.0.1:9000/health >/dev/null 2>&1; do sleep 2; done; curl -s -o /dev/null -w "bucket $RUSTFS_BUCKET create: HTTP %{http_code}\n" -X PUT --aws-sigv4 "aws:amz:us-east-1:s3" --user "$RUSTFS_ACCESS_KEY:$RUSTFS_SECRET_KEY" "http://127.0.0.1:9000/$RUSTFS_BUCKET" ) & exec /entrypoint.sh rustfs'`
- **Health check:** /health
- **Public domain:** Yes

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

- **Image:** paradedb/paradedb:0.25.9-pg17

## Documentation

# Deploy and Host LobeHub on Railway

LobeHub (formerly Lobe Chat) is an open-source AI agent workspace. It gives you a polished chat UI for OpenAI, Anthropic, Google, DeepSeek, Ollama and dozens more providers, plus agents, knowledge bases with RAG, file uploads, image generation, plugins and team accounts, all self-hosted.

## About Hosting LobeHub

LobeHub 2.x only runs in server database mode, so a real deployment is four services: the app, Postgres with the pgvector and pg_search extensions, Redis, and an S3-compatible object store. This template mirrors the official Docker Compose stack: `lobehub/lobehub:2.2.17`, `paradedb/paradedb:0.25.9-pg17` (Postgres 17 with both extensions preinstalled), `redis:7-alpine` and `rustfs/rustfs:1.0.0-rc.6`. Every secret is generated by Railway, every connection is a variable reference, the RustFS bucket is created automatically on first boot, and the app runs its own migrations. Email/password sign-in works out of the box with no third-party identity provider.

## Common Use Cases

- **Team ChatGPT alternative**: one self-hosted UI for every model provider, with per-user API keys or shared keys
- **Agents and knowledge bases**: upload documents, chunk and embed them in pgvector, chat with your data
- **Private AI workspace**: keep prompts, files and conversations on infrastructure you control
- **Multi-provider experimentation**: switch models and compare answers without new tooling
- **Desktop and mobile companion**: pair the LobeHub desktop app or CLI with your own server via OIDC

## Dependencies for LobeHub Hosting

- **PostgreSQL 17 with pgvector and pg_search**: required by the migrations (included as ParadeDB)
- **Redis**: session store and caches (included)
- **S3-compatible storage**: uploads, avatars, knowledge base files (included as RustFS with a public HTTPS endpoint for direct browser uploads)
- **LLM provider keys**: optional at boot; add as variables or per user in Settings

### Deployment Dependencies

- [LobeHub Docker Compose guide](https://lobehub.com/docs/self-hosting/platform/docker-compose)
- [LobeHub environment variables](https://lobehub.com/docs/self-hosting/environment-variables/basic)
- [LobeHub authentication (Better Auth)](https://lobehub.com/docs/self-hosting/auth)
- [LobeHub GitHub repository](https://github.com/lobehub/lobehub)

### Implementation Details

The app image already binds `0.0.0.0:3210`; the template pins `PORT=3210`, `HOSTNAME=0.0.0.0` and health checks `GET /api/version`. `S3_ENDPOINT` is the RustFS public domain because LobeHub signs upload URLs against it and the browser uploads directly. Files are read through short-lived presigned URLs, so the bucket stays private.

```env
APP_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_URL}}
S3_ENDPOINT=https://${{RustFS.RAILWAY_PUBLIC_DOMAIN}}
S3_BUCKET=${{RustFS.RUSTFS_BUCKET}}
KEY_VAULTS_SECRET=${{secret(32)}}
AUTH_SECRET=${{secret(32)}}
```

First steps after deploy: open `/signup` on the LobeHub domain and create your account, then set `AUTH_ALLOWED_EMAILS` to your email or domain so registration is closed to strangers. Add provider keys as variables or in Settings. For desktop, CLI or mobile sign-in, paste a stable `JWKS_KEY` (generate it from the LobeHub docs); otherwise the template generates a fresh key on every deploy and those clients need to sign in again after a redeploy.

## Why Deploy LobeHub 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 LobeHub on Railway, you get the complete official stack (app, ParadeDB Postgres, Redis, RustFS) with generated secrets, health checks, persistent volumes, managed SSL and private networking in one click.


## 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/lobehub-server-postgres
