How to Run Lobe Chat in Production Mode: Docker, Vercel, and Self-Hosting Guide

To run Lobe Chat in production mode, deploy the pre-built Docker image lobehub/lobehub:latest using Docker Compose with the full service stack (PostgreSQL, Redis, RustFS), or host the compiled Next.js application on Vercel with production environment variables configured.

Lobe Chat is a modern AI-agent workspace built on Next.js 16 (App Router) that requires specific backend services to function in production. According to the lobehub/lobe-chat source code, production deployments execute the compiled application via next start -p 3210 rather than the development server, typically within containerized environments or serverless platforms.

Production Architecture Overview

A production-ready Lobe Chat instance consists of the Next.js application serving as both the frontend and API gateway, backed by several persistent services:

  • Next.js Application: The compiled SSR application and API routes exposed on port 3210 (next build && next start -p 3210), as defined in [package.json](https://github.com/lobehub/lobe-chat/blob/canary/package.json#L97)
  • PostgreSQL: Primary database for application state (using postgres:15 or paradedb/paradedb:latest-pg17 for vector search)
  • Redis: Session store and short-term caching (redis:7-alpine)
  • RustFS: Object storage for file uploads (rustfs/rustfs:latest)
  • SearXNG: Optional web-search proxy (searxng/searxng:latest)

These services are orchestrated via the official docker-compose/deploy/docker-compose.yml file, which creates an isolated Docker network named lobe for internal service communication.

Production Deployment Options

The recommended method for self-hosting uses the official Docker Compose configuration to launch the complete service stack.

1. Pull the pre-built image:

docker pull lobehub/lobehub:latest

2. Configure environment variables:

Copy the example environment file and populate it with production secrets:

cp .env.example .env

Edit .env to include DATABASE_URL, REDIS_URL, and your LLM provider API keys (OpenAI, Anthropic, etc.). The full reference is available at .env.example.

3. Launch the full stack:

docker compose -f docker-compose/deploy/docker-compose.yml up -d

The compose file defines the Lobe Chat service as follows:

services:
  lobe:
    image: lobehub/lobehub:latest
    container_name: lobehub
    env_file: .env
    ports:
      - "3210:3210"
    restart: always
    depends_on:
      - postgres
      - redis
      - rustfs

4. Verify the deployment:

Access the application at http://localhost:3210. The container runs next start internally, serving the optimized production build.

Single Container (Quick Test)

For testing without auxiliary services, run the container standalone with external services configured via environment variables:

docker run -it -d \
  --name lobehub \
  -p 3210:3210 \
  --env-file lobe-chat.env \
  --network host \
  lobehub/lobehub:latest

Required minimum environment variables in lobe-chat.env:

DATABASE_URL=postgresql://user:pass@host:5432/lobe
REDIS_URL=redis://host:6379
OPENAI_API_KEY=sk-xxxx

Vercel (Serverless)

Deploy to Vercel's edge network for a managed serverless architecture:

1. Push the repository to GitHub and import the project into Vercel. 2. Add environment variables from .env.example to the Vercel dashboard under Production settings. 3. Deploy. Vercel automatically runs next build and serves the application globally.

The runtime detects Vercel via process.env.VERCEL in [src/envs/app.ts](https://github.com/lobehub/lobe-chat/blob/canary/src/envs/app.ts):

const isInVercel = process.env.VERCEL === '1';
if (isInVercel) {
  // Vercel URL fallback logic
}

Environment Configuration

Production deployments require specific environment variables defined in the application configuration. Key variables include:


# Core Services

DATABASE_URL=postgresql://postgres:mysecretpassword@postgres:5432/lobe
REDIS_URL=redis://redis:6379

# LLM Providers

OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxx

# Application Settings

NEXT_PUBLIC_BASE_URL=https://my-lobe-chat.example.com
NEXT_PUBLIC_HTTPS=true

The production build process is defined in the Dockerfile, which uses Node 18, executes next build, and starts the server with the command specified in [package.json](https://github.com/lobehub/lobe-chat/blob/canary/package.json#L97):

{
  "scripts": {
    "start": "next start -p 3210"
  }
}

Key Production Files

Understanding these source files ensures proper customization of your production deployment:

Summary

  • Run Lobe Chat in production mode using the lobehub/lobehub:latest Docker image with next start -p 3210 as the entry point
  • Use Docker Compose with docker-compose/deploy/docker-compose.yml for the complete self-hosted stack (PostgreSQL, Redis, RustFS)
  • Configure environment variables via .env file based on .env.example before starting the container
  • Deploy to Vercel by pushing the repository and setting production environment variables in the dashboard
  • Verify port 3210 is exposed and accessible for the Next.js server traffic

Frequently Asked Questions

What is the default port for Lobe Chat in production mode?

The production server runs on port 3210 by default. This is hardcoded in the start script within [package.json](https://github.com/lobehub/lobe-chat/blob/canary/package.json#L97) as "start": "next start -p 3210". When using Docker, map this port to your host (e.g., "3210:3210") to access the application.

Can I run Lobe Chat without Docker?

Yes, you can run Lobe Chat without Docker by executing next start -p 3210 directly on a Node.js 18+ server, but you must manually configure and connect PostgreSQL, Redis, and RustFS services. Alternatively, deploy to Vercel for a fully managed serverless environment without container management.

What database does Lobe Chat require for production?

Lobe Chat requires PostgreSQL (version 15 or higher, or ParadeDB with pg17 for vector search capabilities) as its primary database. The application uses Redis for session storage and caching, and RustFS for object storage of uploaded files. These dependencies are defined in the official [docker-compose/deploy/docker-compose.yml](https://github.com/lobehub/lobe-chat/blob/canary/docker-compose/deploy/docker-compose.yml).

How does Lobe Chat detect if it is running on Vercel?

The application checks process.env.VERCEL === '1' in [src/envs/app.ts](https://github.com/lobehub/lobe-chat/blob/canary/src/envs/app.ts) to determine if it is operating within the Vercel serverless environment. This detection affects URL resolution logic, specifically how the base URL is constructed for preview deployments versus production domains.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →