Railway

Deploy LobeChat — Multi-Model AI Chat with RAG [Postgres]

Self-host LobeChat with history, RAG & 40+ providers — server mode

Deploy LobeChat — Multi-Model AI Chat with RAG [Postgres]

Just deployed

Just deployed

/data

/var/lib/postgresql/data

Just deployed

/data

RustFS Init

alpine:latest

Just deployed

Deploy and Host LobeChat on Railway

LobeChat is a polished, open-source AI chat platform — a self-hosted ChatGPT-style interface supporting 40+ model providers (OpenAI, Anthropic, Google, and more), a plugin system, and a document Knowledge Base with RAG. This template deploys the server-database version: LobeChat backed by PostgreSQL with pgvector and S3-compatible storage, so your chat history persists, syncs across devices, and the Knowledge Base actually works.


What This Template Deploys

ServicePurpose
LobeChatThe chat UI, plugin system, and API (server-database build) on port 3210
PostgreSQL + pgvectorUsers, chat history, settings, and RAG document embeddings
MinIO (S3)File and image storage — required for uploads and the Knowledge Base

All services run on Railway's private network. This is the full server deployment, not the browser-only single-container mode.


About Hosting LobeChat

LobeChat ships in two very different modes, and choosing wrong is the most common self-hosting mistake.

The default single-container image stores everything in the browser — no server-side history, no cross-device sync, and the Knowledge Base doesn't function. It's fine for a personal scratchpad and useless as a team or multi-device deployment.

This template runs the server-database version, which persists everything properly. That requires three pieces wired together, and one of them catches almost everyone:

  • PostgreSQL with pgvector stores accounts, history, and the RAG embeddings for the Knowledge Base
  • KEY_VAULTS_SECRET encrypts the API keys users store — set once, keep stable, or stored keys become unreadable
  • S3-compatible storage is mandatory, not optional. LobeChat has no local-disk fallback for file uploads, so without S3 the Knowledge Base and file attachments silently fail. This template includes MinIO as that storage layer

One more setting matters: APP_URL must be your real public domain. OAuth callbacks and async features like AI image generation make requests against it, and if it's wrong they fail without an obvious error.

LobeChat delegates inference to external providers, so no GPU is needed — connect cloud models and it runs on CPU.

Typical cost: ~$10–20/month on Railway for LobeChat, Postgres, and MinIO, plus your model providers' usage. LobeChat is Apache-2.0 with no paid tier for self-hosting.


How It Compares

LobeChat server (this template)LobeChat browser modeChatGPT TeamLibreChat
Cost modelFlat ~$10–20/mo infra~$5/mo, no persistencePer user/monthSelf-hosted
Chat historyServer-side, syncedBrowser onlyVendorServer-side
Knowledge Base (RAG)YesNoLimitedYes
Providers40+40+OpenAI onlyMany
Cross-device syncYesNoYesYes
Self-hostableYesYesNoYes

ChatGPT Team is polished but OpenAI-only and per-seat. LibreChat is a strong alternative aimed at multi-user teams. LobeChat's server mode stands out on interface polish, its plugin ecosystem, and 40+ providers — with the persistence and RAG that browser mode lacks.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway — LobeChat, PostgreSQL, and MinIO build automatically (~4 minutes)
  2. Confirm KEY_VAULTS_SECRET and NEXT_AUTH_SECRET are generated (each openssl rand -base64 32)
  3. Set APP_URL to your Railway public domain — OAuth and image generation depend on it
  4. Confirm the S3_* variables point at the MinIO service
  5. Open your domain, create an account, then add provider API keys under Settings → Model Provider

Keys are encrypted with KEY_VAULTS_SECRET and stored per user, so each person can bring their own.


Common Use Cases

  • Private multi-provider AI hub — one polished interface across OpenAI, Anthropic, Google, and 40+ providers, keys encrypted server-side
  • Team AI workspace — server-side history and cross-device sync so a whole team shares one deployment
  • Document Q&A with RAG — upload files to the Knowledge Base and query them with any connected model
  • Plugin-extended assistant — web search, code execution, and other plugins extend what the chat can do
  • Provider cost management — centralize keys and usage across models instead of scattering them across apps
  • Privacy-first AI — conversations and documents stay on infrastructure you control

Configuration

VariableRequiredDescription
DATABASE_URLAuto-injectedPostgreSQL connection via Railway reference variable
KEY_VAULTS_SECRETRequiredEncrypts stored provider keys — openssl rand -base64 32, keep stable
NEXT_AUTH_SECRETRequiredAuthentication session secret — openssl rand -base64 32
APP_URLRequiredYour Railway public domain — OAuth and async features depend on it
NEXT_AUTH_SSO_PROVIDERSOptionalSSO providers, e.g. github, auth0, logto
S3_ENDPOINTRequiredMinIO/S3 endpoint — required for uploads and Knowledge Base
S3_BUCKETRequiredStorage bucket name
S3_ACCESS_KEY_IDRequiredS3 access key
S3_SECRET_ACCESS_KEYRequiredS3 secret key
S3_PUBLIC_DOMAINRequiredPublic URL for served files
NEXT_PUBLIC_ENABLE_NEXT_AUTHOptionalSet 1 to enable authentication

S3 storage is required, not optional. LobeChat has no local-disk fallback for uploads. Without working S3, file attachments and the Knowledge Base silently fail. This template includes MinIO for it.

Keep KEY_VAULTS_SECRET and NEXT_AUTH_SECRET stable. The first encrypts stored provider keys; changing it makes them unreadable. Both are generated at deploy — back them up and don't rotate them.


Dependencies for LobeChat Hosting

  • Railway account — expect ~$10–20/month for LobeChat, Postgres, and MinIO
  • At least one model provider API key (OpenAI, Anthropic, Google, etc.)
  • S3-compatible storage (MinIO included) for uploads and the Knowledge Base
  • Optional: an OAuth provider (GitHub, Auth0, Logto) for SSO and team features

Deployment Dependencies

Implementation Details

The template runs the lobehub/lobe-chat-database image on port 3210 — the server-database build, not the browser-only default — against a PostgreSQL service with the pgvector extension and a MinIO service for S3-compatible storage. All three communicate over Railway's private network.

KEY_VAULTS_SECRET encrypts the provider API keys users store, and NEXT_AUTH_SECRET secures authentication sessions; both are generated at deploy and must remain stable, since changing the vault secret renders stored keys unreadable. pgvector powers the Knowledge Base: uploaded documents are embedded and stored for semantic search, which is why the database extension and the S3 storage layer are both required rather than optional.

APP_URL must match the public domain, because OAuth callbacks and LobeChat's async features (such as AI image generation) make requests against it — a common cause of silent failures when it's left at a default. Inference is delegated to external providers, so the deployment runs on CPU with no GPU.


Frequently Asked Questions

Why is S3 storage required? LobeChat's server version stores file uploads and Knowledge Base documents in S3-compatible storage, with no local-disk fallback. Without it, attachments and RAG silently fail. This template includes MinIO so both work out of the box.

What's the difference from the single-container version? The default single-container image keeps everything in the browser — no server history, no sync, no working Knowledge Base. This template runs the server-database version, which persists history, syncs across devices, and enables RAG.

How do I add API keys? After logging in, go to Settings → Model Provider and enter keys for OpenAI, Anthropic, Google, and 40+ others. They're encrypted with KEY_VAULTS_SECRET and stored per user.

Does my chat history persist? Yes. In server-database mode, history, settings, and Knowledge Base data live in PostgreSQL and persist across redeploys and devices. Back the database up on a schedule.

Can I use local models like Ollama? LobeChat supports Ollama as a provider, but Ollama needs a GPU, which Railway doesn't provide. Point LobeChat at an Ollama instance running on a separate GPU host.

Why does image generation fail? Usually APP_URL doesn't match your real domain. LobeChat's async features call back against it, so it must be set correctly.

Is it free? Yes. LobeChat is Apache-2.0 with the full feature set available self-hosted and no paid tier.


Why Deploy LobeChat 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 LobeChat on Railway you get the full server-database experience with the pieces that browser mode lacks — PostgreSQL with pgvector, MinIO for uploads and RAG, encrypted key vaults, and automatic HTTPS. Persistent history, a working Knowledge Base, 40+ providers, and your conversations on infrastructure you own.


Template Content

More templates in this category

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

okisdev
113
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
1
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
51