Deployment Getting Started
Guides, route-group overviews, and live schema entry points for the Plexichat backend.
Deployment guide
Install, configure, and run Plexichat in production. For subsystem-specific options, see the configuration pages linked in each section.
Contents
- System requirements
- Installation
- Create configuration
- Security hardening
- Service management
- Verification
- Monitoring
- Backup and recovery
- Troubleshooting
System requirements
Minimum
- CPU: 2 cores
- RAM: 4 GB
- Disk: 10 GB SSD
- OS: Linux (Ubuntu 22.04 or later, Debian 12 or later, CentOS Stream 9 or later)
- Python: 3.14 or later (the server image uses
python:3.14.8-slim-trixieatplexichat/Dockerfile:1; 3.11 and 3.13 are not supported)
Recommended for production
- CPU: 4 or more cores
- RAM: 8 GB or more (16 GB for large deployments or when ClamAV is enabled)
- Disk: 50 GB or more SSD, plus external storage for media
- Network: 1 Gbps or more for media-heavy deployments
Service dependencies
- Database: PostgreSQL 18 (
postgres:18-alpineinplexichat/docker-compose.yml) or SQLite for small and development deployments only - Cache: Valkey 9.1 (
valkey/valkey:9.1.1-alpineinplexichat/docker-compose.yml), required for production and for multi-worker scaling - Reverse proxy: Nginx (bundled as
clientatplexichat-client/Dockerfile:9), or Caddy, Apache, or Traefik for TLS termination - Optional: S3-compatible storage (RustFS 1.0 at
plexichat/docker-compose.yml, AWS S3, or similar) for media
For detailed requirements, see System requirements.
Installation
Step 1: Prepare the system
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3.14 python3.14-venv python3.14-dev git build-essential \
libpq-dev libopus-dev libsrtp2-dev libvpx-dev ffmpeg curl
# Install PostgreSQL (if you run Postgres outside Docker)
sudo apt install -y postgresql postgresql-contrib
# Install Valkey (if you run Valkey outside Docker)
sudo apt install -y valkey-server
sudo systemctl enable valkey-server
sudo systemctl start valkey-server
The backend requires the same system libraries as the Docker image (plexichat/Dockerfile:8).
Step 2: Clone the repository
git clone https://gitlab.plexichat.com/plexichat/plexichat.git
cd plexichat/plexichat
Step 3: Create a virtual environment
python3.14 -m venv .venv
source .venv/bin/activate
Step 4: Install dependencies
pip install --upgrade pip setuptools wheel
pip install --require-hashes -r requirements.txt
Step 5: Create configuration
Create config/config.yaml. Plexichat merges this file over built-in defaults from src/config_defaults.py and generates a working default on first run if the file is missing. Use the default configuration reference as the authoritative list of keys and defaults.
Do not copy docs/default-config.md as a config file. It is Markdown with code fences, not valid YAML.
Set these keys for production:
application:
environment: "production"
database:
type: "postgres"
postgres:
host: "${POSTGRES_HOST:-localhost}"
password: "${POSTGRES_PASSWORD}"
sslmode: "require"
valkey:
enabled: true
password: "${VALKEY_PASSWORD}"
logging:
level: "INFO"
include_exception_details: false
api:
debug: false
Then consult the subsystem pages for the features you use:
- Database configuration - PostgreSQL setup, pooling, migrations
- Redis configuration - Caching, sessions, pooling
- Authentication configuration - Password policies, 2FA, sessions, account deletion
- Media configuration - Storage backends, limits, processing, security
- Voice configuration - SFU backends, STUN/TURN, NAT traversal
- WebSocket configuration - Gateway settings, compression, rate limits
- Rate limiting configuration - Global, user, IP, bot, and webhook limits
- API and server configuration - CORS, trusted proxies, debug mode, TLS
- Search configuration - Search backends, indexing, result limits
- Email configuration - SMTP for verification and notifications
- Embeds configuration - URL previews and link embeds
Step 6: Set environment variables
Plexichat supports ${VAR_NAME} and ${VAR_NAME:-default} interpolation in config files.
# Required for production encryption
export PLEXICHAT_SYSTEM_KEY="your_encryption_key"
# Database
export POSTGRES_PASSWORD="your_secure_password"
# Valkey
export VALKEY_PASSWORD="your_valkey_password"
# S3 (if you use external media storage)
export S3_BUCKET="your-bucket-name"
export S3_ACCESS_KEY="your_access_key"
export S3_SECRET_KEY="your_secret_key"
Store these values in a .env file, add .env to .gitignore, and set chmod 600 .env.
First run
On first startup, Plexichat inspects config/config.yaml and generates any per-installation secrets that still use placeholder defaults:
media.signing_key- If the value is stillCHANGE_THIS_SIGNING_KEYor empty, the server generates a 32-byte secret withsecrets.token_hex(32), writes it to themedia:section, and reuses it on later starts. Treat it as a production secret. To rotate it, set a newmedia.signing_keyvalue inconfig/config.yamlbefore restarting;python main.py rotate-secretsonly rotatesapplications.webhook_signature_secret, not this key.applications.webhook_signature_secret- Generated with the same pattern duringinitializer.initialize_modules.
To supply your own value, set media.signing_key in config/config.yaml before the first run. The server skips generation when the key is already set.
Docker deployment
For containerized deployment, use Docker or Docker Compose. This is the recommended approach for production.
Quick start with Docker
# Build the image (uses python:3.14.8-slim-trixie)
docker build -f plexichat/Dockerfile -t plexichat:latest plexichat
# Run with environment variables
docker run -d \
--name plexichat \
-p 8000:8000 \
-p 30000-30100:30000-30100/udp \
-e PLEXICHAT_SYSTEM_KEY="your_encryption_key" \
-e POSTGRES_PASSWORD="your_db_password" \
-e VALKEY_PASSWORD="your_valkey_password" \
-v $(pwd)/plexichat/config:/app/config \
-v plexichat_home:/home/plexichat/.plexichat \
plexichat:latest
The image exposes 8000/TCP and 30000-30100/UDP for voice media (plexichat/Dockerfile:40) and runs as the non-root user plexichat (UID 10001 at plexichat/Dockerfile:34).
Docker Compose (recommended)
Use the canonical plexichat/docker-compose.yml. Do not hand-write a minimal compose.yml unless you understand the required dependencies (db, valkey, rustfs, rustfs-init, clamav, backend, client).
Create your .env from plexichat/.env.example:1, then start:
BACKEND_VERSION=latest CLIENT_VERSION=latest docker compose -f plexichat/docker-compose.yml up -d
What the Compose file provides:
backendon8000/TCPand30000-30100/UDP(plexichat/docker-compose.yml), health checkcurl -sf http://localhost:8000/api/v1/ready(plexichat/docker-compose.yml)clientNginx on80and443(plexichat/docker-compose.yml), proxying/api/,/gateway,/docs, and/openapi.jsontobackend:8000(plexichat-client/docker/nginx/default.conf:12)dbon internal5432,valkeyon internal6379,rustfson internal9000/9001(exposed, not published),clamavon internal3310backupwith restic, supercronic scheduling, and/scripts/healthcheck.shliveness (plexichat/docker-compose.yml)
To override ports or add host mounts, create docker-compose.override.yml next to plexichat/docker-compose.yml.
Environment variables
Create plexichat/.env from the example:
umask 077
cp plexichat/.env.example plexichat/.env
chmod 600 plexichat/.env
# Set strong values for POSTGRES_PASSWORD, VALKEY_PASSWORD, S3_ACCESS_KEY,
# S3_SECRET_KEY, and BACKUP_RESTIC_PASSWORD.
Or generate values (under umask 077 so the secrets file is created 0600
even if chmod below were skipped):
umask 077
echo "PLEXICHAT_SYSTEM_KEY=$(openssl rand -hex 32)" >> plexichat/.env
echo "POSTGRES_PASSWORD=$(openssl rand -base64 32)" >> plexichat/.env
echo "VALKEY_PASSWORD=$(openssl rand -base64 32)" >> plexichat/.env
chmod 600 plexichat/.env
Database migrations in Docker
Plexichat runs pending migrations automatically on startup. To run them manually:
# Run migrations inside the backend container
docker compose -f plexichat/docker-compose.yml exec backend python -m src.core.migrations.cli apply_migrations
# Trigger a backup now
docker compose -f plexichat/docker-compose.yml exec backup /scripts/backup.sh run
Health checks
The Docker setup includes health checks for core services (plexichat/docker-compose.yml, plexichat/docker-compose.yml):
backend:
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8000/api/v1/ready"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
Use /api/v1/ready for readiness (returns {"status":"ready"} at src/api/routes/health.py) and /api/v1/health for deep health including cross_worker_listener status.
Security hardening
Firewall
# Allow SSH
sudo ufw allow 22/tcp
# Allow HTTP/HTTPS when you terminate TLS at the reverse proxy
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Allow the Plexichat backend directly only if you publish it outside Nginx
# Otherwise, block 8000 and rely on Nginx at 443
sudo ufw allow 8000/tcp # Remove this rule if you keep backend internal
sudo ufw allow 30000:30100/udp # Voice media (SFU)
# Enable firewall
sudo ufw enable
Dedicated service user
sudo useradd -r -s /bin/false plexichat
sudo chown -R plexichat:plexichat /opt/plexichat
sudo chmod 750 /opt/plexichat
The Docker image already runs as plexichat (UID 10001). For bare-metal installs, run the process as the same unprivileged user.
TLS through a reverse proxy (Nginx)
server {
listen 443 ssl http2;
server_name chat.example.com;
ssl_certificate /etc/ssl/certs/chat.example.com.crt;
ssl_certificate_key /etc/ssl/private/chat.example.com.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# Match the backend body cap (10 MB). Nginx default is 1 MB.
client_max_body_size 10m;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}
The /gateway WebSocket path is served by the same application on the same port. The location / block covers it. You need a separate /gateway block only if you want different timeouts (see plexichat-client/docker/nginx/default.conf:90).
For full guidance, see Security best practices.
Service management
Systemd service
# /etc/systemd/system/plexichat.service
[Unit]
Description=Plexichat Server
After=network.target postgresql.service valkey.service
[Service]
Type=notify
User=plexichat
Group=plexichat
WorkingDirectory=/opt/plexichat
Environment="PATH=/opt/plexichat/.venv/bin"
ExecStart=/opt/plexichat/.venv/bin/python main.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
main.py starts Uvicorn with the configured host, port, and workers. You can also run uvicorn src.api.app:create_app --factory --host 0.0.0.0 --port 8000 --workers 4 directly.
Enable and start:
sudo systemctl daemon-reload
sudo systemctl enable plexichat
sudo systemctl start plexichat
sudo systemctl status plexichat
Worker count
Calculate workers from CPU cores: workers = (2 * CPU cores) + 1.
For multi-worker deployments, Valkey is required for shared session state and cross-worker events (plexichat:events:cross_worker).
Horizontal scaling
For large deployments (>1,000 users), run multiple backend instances behind a load balancer with:
- Shared PostgreSQL 18 database
- Shared Valkey 9.1 instance
- Shared media storage (S3 or shared filesystem)
- Sticky sessions for WebSocket connections (
ip_hashin Nginx)
See Production setup.
Verification
Health checks
curl https://chat.example.com/api/v1/ready
# {"status":"ready"}
curl https://chat.example.com/api/v1/health
# {"status":"healthy","version":"1.0.0a239",...}
curl https://chat.example.com/api/v1/status
# Server state, version, uptime, maintenance info
Inside Docker:
curl -sf http://localhost:8000/api/v1/ready
curl -sf http://localhost:8000/api/v1/health | jq .
API documentation
- Swagger UI:
/docs(through Nginx athttps://chat.example.com/docs, directly athttp://localhost:8000/docs) - ReDoc:
/redoc - OpenAPI spec:
/openapi.json
WebSocket test
wscat -c wss://chat.example.com/gateway
Direct to the backend:
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" \
http://localhost:8000/gateway
# Expect 101 Switching Protocols
Database and Valkey
psql -h localhost -U plexichat -d plexichat -c "SELECT 1;"
valkey-cli -h localhost -p 6379 ping
# Or inside Compose:
docker compose -f plexichat/docker-compose.yml exec db psql -U plexichat -d plexichat -c "SELECT 1;"
docker compose -f plexichat/docker-compose.yml exec valkey sh -c 'REDISCLI_AUTH="$VALKEY_PASSWORD" redis-cli ping'
Monitoring
Application metrics
Control telemetry in config:
monitoring:
enabled: true
log_interval: 300
metrics_enabled: true
alert_thresholds:
cpu_percent: 80
memory_percent: 85
db_pool_saturation_percent: 75
query_time_ms: 5000
db_errors_per_minute: 10
api_response_time_ms: 2000
error_rate_percent: 5
active_connections: 1000
There is no built-in Prometheus /metrics endpoint. Scrape /api/v1/health and /api/v1/ready or consume /api/v1/status for uptime and version. Export custom metrics if you need Prometheus format.
Key metrics to monitor
- Request rate and response times (P50, P95, P99)
- HTTP 5xx error rate
- Database connection pool saturation (
DB_POOL_*inplexichat/.env.example:28) - Valkey cache hit and miss rates
- WebSocket connection count and
cross_worker_listenerstatus from/api/v1/health - CPU and memory utilization
Logging
Logs are written to ~/.plexichat/logs/:
plexichat.log- Main application logerror.log- Error-level messages
Configure rotation:
sudo cat > /etc/logrotate.d/plexichat << 'EOF'
/home/plexichat/.plexichat/logs/*.log {
daily
rotate 14
compress
delaycompress
notifempty
create 0640 plexichat plexichat
sharedscripts
postrotate
systemctl reload-or-restart plexichat
endscript
}
EOF
Backup and recovery
Database backups (PostgreSQL)
pg_dump -h localhost -U plexichat plexichat | gzip > /backups/plexichat-$(date +%Y%m%d).sql.gz
Automate with cron:
0 2 * * * pg_dump -h localhost -U plexichat plexichat | gzip > /backups/plexichat-$(date +\%Y\%m\%d).sql.gz
For Docker, use the backup service:
docker compose -f plexichat/docker-compose.yml exec backup /scripts/backup.sh run
docker compose -f plexichat/docker-compose.yml exec backup /scripts/backup.sh list
Media backups
- Local storage:
rsync -av /home/plexichat/.plexichat/media/ /backups/media/ - S3 or RustFS: Enable versioning and lifecycle policies in the bucket
- Docker: The
backupservice includesplexichat_homeandrustfs_datawhenBACKUP_INCLUDE_HOME=trueandBACKUP_INCLUDE_MEDIA=true(plexichat/docker-compose.yml)
Configuration backups
cp config/config.yaml /backups/config-$(date +%Y%m%d).yaml
cp plexichat/.env /backups/env-$(date +%Y%m%d).bak
chmod 600 /backups/env-*.bak
Recovery procedure
- Stop the Plexichat service.
- Restore the database from backup.
- Restore the media directory (if you use local storage).
- Restore configuration and
.env. - Start the service.
- Verify
curl -sf http://localhost:8000/api/v1/readyreturns{"status":"ready"}.
Troubleshooting
Server does not start
sudo systemctl status plexichat
sudo journalctl -u plexichat -n 100
tail -100 ~/.plexichat/logs/plexichat.log
Common causes: database connection failure (check POSTGRES_* in .env), Valkey connection failure (check VALKEY_PASSWORD), config YAML syntax error, or port already in use (8000/TCP or 30000–30100/UDP).
Database connection errors
Verify PostgreSQL is running, credentials match, and sslmode is correct for your environment. Inside Docker, check:
docker compose -f plexichat/docker-compose.yml exec backend env | grep POSTGRES
docker compose -f plexichat/docker-compose.yml logs db --tail 50
WebSocket issues
Verify the reverse proxy sets Upgrade and Connection: upgrade and uses long timeouts (plexichat-client/docker/nginx/default.conf:90). Check firewall rules for 443 and for 30000–30100/UDP if you use voice.
Get help
- Collect relevant logs.
- Document system configuration and version (
curl -sf http://localhost:8000/api/v1/health). - Check the configuration overview and subsystem pages.
- Verify all dependencies are healthy (
docker compose ps).
Related documentation
- Configuration overview - Config discovery and module guides
- Default configuration reference - Every key with defaults
- Authentication configuration - Password, 2FA, sessions, deletion
- Database configuration - PostgreSQL and SQLite setup
- Valkey configuration - Caching and sessions
- Media configuration - Storage and processing
- Voice configuration - Voice and video setup
- Docker deployment - Containerized deployment
- Security best practices - Production security
- Performance guide - Optimization