Bitdoze logo

Self-Host Convex in 2026: Docker Compose & Dokploy Guide

Learn to self-host Convex on your VPS with Docker Compose or Dokploy. Covers SQLite, PostgreSQL, MySQL, reverse proxy, S3 storage, and Prometheus metrics.

Dragos

Updated Published 28 min read

Self-Host Convex in 2026: Docker Compose & Dokploy Guide

Disclosure: this guide contains referral links. If you buy through them, I may earn a commission at no extra cost to you.

If you are building real-time applications with databases, you have probably run into Convex. It is a backend-as-a-service platform that combines a real-time database with serverless functions. The cloud free tier gives you 0.5GB database storage and 1M function calls per month, which works for small projects. Self-hosting removes those limits and gives you control over your data and infrastructure.

The self-hosted path is first-party now. Convex open-sourced the backend in November 2025, and the repo (convex/convex-backend) sits at roughly 12,700 GitHub stars with near-weekly precompiled-* releases. The npm convex package is at 1.47.0 with around 1.1M weekly downloads. The maintainers state the public repo is synced with their internal code within a handful of days, so you are not running an abandoned fork.

In this guide, I walk through self-hosting Convex using either Dokploy (simpler) or Docker Compose (more control). SQLite covers small setups; PostgreSQL or MySQL covers production. A $5-10 VPS is enough for a solo deployment.

What is Convex?

Convex is a backend platform that combines databases, API servers, and caching layers into one system. It handles real-time data synchronization, serverless functions, and caching using a TypeScript API. The self-hosted build is the same codebase the cloud runs, licensed under FSL 1.1, which converts to full Apache 2.0 two years after each release.

Key Features of Convex

  • Real-Time Database: Automatic data synchronization across all clients with reactive queries
  • TypeScript-First: End-to-end type safety from backend to frontend
  • Serverless Functions: Write queries, mutations, and actions in TypeScript without managing servers
  • Built-in Scheduling: Cron jobs and scheduled functions without external services
  • File Storage: Built-in file upload and storage with CDN distribution
  • Full-Text Search: Native search capabilities without Elasticsearch
  • Authentication: Flexible auth system supporting various providers
  • Atomic Transactions: ACID guarantees for data consistency
  • Time Travel: Query historical data and debug with time-travel queries
  • Vector Search: Built-in vector database for AI applications

Why Self-Host Convex?

Self-hosting advantages:

  • You own the data and control where it lives
  • No bandwidth or function execution caps
  • Customize infrastructure and scaling
  • Lower costs at scale
  • Run on-premises or in private networks

Cloud plans in 2026 look like this: Free and Starter include 1M function calls, 0.5GB database storage, and 1GB file storage, then bill pay-as-you-go overages. Professional starts at $25 per developer per month and adds 25M function calls, 50GB database storage, daily backups, and custom domains. Business and Enterprise start at $2,500 per month for SAML/SSO, SLAs, and dedicated deployments.

When self-hosting pays off

Paid cloud starts at $25/dev/month. A $5-10 VPS covers a solo self-hosted deployment. Self-host when you hit the free-tier caps, need data residency control, or want a single production box instead of a per-seat bill. For numbers from an actual load test, see our self-hosted Convex vs cloud benchmarks.

How Self-Hosted Convex Runs

A self-hosted deployment is three Convex services plus your frontend. The backend listens on port 3210 for the API and query sync. HTTP actions sit on port 3211. The dashboard listens on 6791 and talks to the backend through a URL the browser can reach. Data lives either in a SQLite file on a Docker volume or in an external Postgres/MySQL instance. The npx convex CLI pushes functions and reads data using an admin key.

Your app / browserqueries, mutations, HTTP actionsnpx convex CLIadmin key deploy + exportConvex backend :3210CONVEX_CLOUD_ORIGINHTTP actions :3211CONVEX_SITE_ORIGINDashboard :6791NEXT_PUBLIC_DEPLOYMENT_URLStorageSQLite volume, orPostgres / MySQLbrowser reaches dashboarddata
Three Convex services and one storage backend. The env vars decide which hostname each port is published under.

Prerequisites

You’ll need:

  • A VPS or Server: 2GB RAM minimum, 2 CPU cores (4GB RAM recommended for PostgreSQL)
  • A Domain Name: Three hostnames is the clean setup (api, actions, dashboard under your domain)
  • Docker Installed: Docker and the docker compose plugin (Dokploy includes Docker)
  • Basic Command Line Knowledge: For running commands
  • openssl: For generating INSTANCE_SECRET
  • Node.js 18+ and npx: The Convex CLI needs this for deploys, exports, and admin key work
  • DNS A Records: Point the hostnames at the VPS before the reverse-proxy step
Try Hetzner Cloud Now Try Hostinger VPS

VPS prices jumped across the board in 2026. If you’re rethinking a rented box, see what changed and when a mini PC wins.

Hosting Recommendations

For development, a basic VPS with 2GB RAM works fine with SQLite. For production, use 4GB RAM with PostgreSQL hosted in the same region. Hetzner, DigitalOcean, and AWS all work. Pick your domain names now: changing CONVEX_CLOUD_ORIGIN or CONVEX_SITE_ORIGIN later means a backend restart and a re-deploy of your functions.

Option 1: Deploy with Dokploy (Easiest Method)

Dokploy is an open-source Platform as a Service for deploying applications, and it ships a Convex template. I default to Dokploy for single-server deployments because it handles Traefik, SSL, and redeploys without extra tooling. If you want the comparison of the PaaS options, read the Coolify vs Dokploy vs Kamal 2 comparison. If you haven’t set up Dokploy yet, use the Dokploy Installation Guide.

This is the fastest way to deploy Convex. The template gets you running in minutes, but it is currently stale, so you will edit the compose file before deploying. If you are new to compose-based apps in Dokploy, how to deploy a Docker Compose app in Dokploy covers the generic flow.

Step 1: Install Dokploy (if not already installed)

bash
curl -sSL https://dokploy.com/install.sh | sh

Access Dokploy at http://your-vps-ip:3000 and complete the setup.

Step 2: Deploy from Template

  1. Log in to Dokploy dashboard
  2. Click “Create Project” and name it (e.g., “Convex”)
  3. Click “Templates” in the left sidebar
  4. Search for “Convex” in the template gallery
  5. Click “Deploy” on the Convex template

Step 3: Replace the Compose File

The Dokploy Template Is Stale

The official blueprint still pins images from the old ghcr.io/get-convex namespace, uses the removed ACTIONS_USER_TIMEOUT_SECS variable, carries legacy DATABASE_URL, and ships SQLite-only. The old namespace now denies anonymous pulls. Open the Docker Compose tab before you deploy and paste the corrected compose below.

This is the compose I would run from Dokploy’s Docker Compose tab:

yaml
services:
  backend:
    image: ghcr.io/convex/convex-backend:latest   # pin backend+dashboard to the SAME SHA for prod
    volumes:
      - data:/convex/data
    environment:
      - INSTANCE_NAME=${INSTANCE_NAME:-convex-self-hosted}
      - INSTANCE_SECRET=${INSTANCE_SECRET}
      - CONVEX_CLOUD_ORIGIN=${CONVEX_CLOUD_ORIGIN:-http://127.0.0.1:3210}
      - CONVEX_SITE_ORIGIN=${CONVEX_SITE_ORIGIN:-http://127.0.0.1:3211}
      - POSTGRES_URL=${POSTGRES_URL:-}
      - DISABLE_BEACON=${DISABLE_BEACON:-true}
      - V8_ACTION_USER_TIMEOUT_SECS=${V8_ACTION_USER_TIMEOUT_SECS:-}
      - NODE_ACTION_USER_TIMEOUT_SECS=${NODE_ACTION_USER_TIMEOUT_SECS:-}
      - DISABLE_METRICS_ENDPOINT=${DISABLE_METRICS_ENDPOINT:-true}
      - DOCUMENT_RETENTION_DELAY=${DOCUMENT_RETENTION_DELAY:-172800}
      - RUST_LOG=${RUST_LOG:-info}
      - DO_NOT_REQUIRE_SSL=${DO_NOT_REQUIRE_SSL:-1}
    healthcheck:
      test: curl -f http://localhost:3210/version
      interval: 5s
      start_period: 5s

  dashboard:
    image: ghcr.io/convex/convex-dashboard:latest  # must match backend version
    environment:
      - NEXT_PUBLIC_DEPLOYMENT_URL=${NEXT_PUBLIC_DEPLOYMENT_URL:-http://127.0.0.1:3210}
      - NEXT_PUBLIC_LOAD_MONACO_INTERNALLY=${NEXT_PUBLIC_LOAD_MONACO_INTERNALLY:-}
    depends_on:
      backend:
        condition: service_healthy

Template Flexibility

The Dokploy template is a starting point. Edit the Docker Compose configuration and the environment variables to match this snippet, then add the Postgres service from Option 2 if you want a production database.

SQLite vs PostgreSQL vs MySQL

Leave POSTGRES_URL and MYSQL_URL empty and Convex uses SQLite. For production, set POSTGRES_URL for PostgreSQL or MYSQL_URL for MySQL. MySQL support was added in February 2025.

Configure Environment Variables (Dokploy)

Go to the Environment tab and add these variables.

Required:

  • INSTANCE_SECRET: Generate with openssl rand -hex 32

INSTANCE_SECRET Is Your Root Credential

Admin keys are derived from INSTANCE_NAME + INSTANCE_SECRET. Lose the secret and you cannot generate new admin keys. Rotate it and every existing admin key breaks. Store it in your password manager and in your backups.

URLs - choose one option.

Option A: Dokploy’s free Traefik domains (quick start)

bash
NEXT_PUBLIC_DEPLOYMENT_URL=http://shhosted-convex-cf33fb-91-98-95-196.traefik.me
CONVEX_CLOUD_ORIGIN=http://shhosted-convex-cf33fb-91-98-95-196.traefik.me
CONVEX_SITE_ORIGIN=http://shhosted-convex-59a34c-91-98-95-196.traefik.me

CONVEX_SITE_ORIGIN is a different hostname from the other two. It must reach port 3211 (HTTP actions), not 3210.

Option B: Your own domain (production)

Set up DNS A records first, then:

bash
CONVEX_CLOUD_ORIGIN=https://api.convex.yourdomain.com
CONVEX_SITE_ORIGIN=https://actions.convex.yourdomain.com
NEXT_PUBLIC_DEPLOYMENT_URL=https://api.convex.yourdomain.com

CONVEX_CLOUD_ORIGIN and NEXT_PUBLIC_DEPLOYMENT_URL point at the hostname that reaches 3210. CONVEX_SITE_ORIGIN points at the hostname that reaches 3211. If NEXT_PUBLIC_DEPLOYMENT_URL is left at 127.0.0.1, the dashboard will load in your browser but every query hangs.

PostgreSQL (optional, leave empty to use SQLite):

bash
DB_PASSWORD=your-strong-password
POSTGRES_URL=postgresql://postgres:your-strong-password@postgres:5432

Pass POSTGRES_URL without a database name and without query parameters. Convex names the database after the instance, with - mapped to _, so the default instance convex-self-hosted uses database convex_self_hosted.

Deploy, Generate Admin Key & Verify

  1. In the Domains tab, add your hostnames. Dokploy’s Traefik issues the SSL certificates.
  2. Click “Deploy” and wait for the services to go healthy.
  3. Open Terminal on the backend container and run:
bash
cd convex
./generate_admin_key.sh
  1. Save the admin key securely. Treat it like a root password.

Verify the deployment before you connect any app:

  • Dokploy shows the backend service as healthy
  • curl http://localhost:3210/version from the VPS returns a JSON version payload
  • The dashboard loads at :6791 or at your dashboard domain
  • The admin key is saved and starts with convex-self-hosted| (or whatever you set INSTANCE_NAME to)

If /version does not answer, the backend is not up. Read docker compose logs backend or the log pane in Dokploy before touching anything else.

Option 2: Deploy with Docker Compose Only

If you prefer deploying without Dokploy or want more control, use Docker Compose directly.

Step 1: Prepare Your Server

Update the system and install Docker. The official installer ships the Compose plugin, so there is nothing extra to install:

bash
# Update packages
sudo apt update && sudo apt upgrade -y

# Install Docker (includes the docker compose plugin)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Confirm compose is available
docker compose version

docker-compose (hyphen) is the old v1 tool and is end-of-life. Everything below uses docker compose (space).

Step 2: Create Project Directory

bash
mkdir -p ~/convex-backend
cd ~/convex-backend

Step 3: Create the Docker Compose File

Pick one of the two variants and save it as docker-compose.yml (or compose.yml).

SQLite (simple)

yaml
services:
  backend:
    image: ghcr.io/convex/convex-backend:latest
    stop_grace_period: 10s
    stop_signal: SIGINT
    ports:
      - "3210:3210"
      - "3211:3211"
    volumes:
      - data:/convex/data
    environment:
      - INSTANCE_NAME=${INSTANCE_NAME:-convex-self-hosted}
      - INSTANCE_SECRET=${INSTANCE_SECRET}
      - CONVEX_CLOUD_ORIGIN=${CONVEX_CLOUD_ORIGIN:-http://127.0.0.1:3210}
      - CONVEX_SITE_ORIGIN=${CONVEX_SITE_ORIGIN:-http://127.0.0.1:3211}
      - V8_ACTION_USER_TIMEOUT_SECS=${V8_ACTION_USER_TIMEOUT_SECS:-}
      - NODE_ACTION_USER_TIMEOUT_SECS=${NODE_ACTION_USER_TIMEOUT_SECS:-}
      - DISABLE_METRICS_ENDPOINT=${DISABLE_METRICS_ENDPOINT:-true}
      - DOCUMENT_RETENTION_DELAY=${DOCUMENT_RETENTION_DELAY:-172800}
      - RUST_LOG=${RUST_LOG:-info}
      - DISABLE_BEACON=${DISABLE_BEACON:-false}
    healthcheck:
      test: curl -f http://localhost:3210/version
      interval: 5s
      start_period: 10s

  dashboard:
    image: ghcr.io/convex/convex-dashboard:latest
    stop_grace_period: 10s
    stop_signal: SIGINT
    ports:
      - "6791:6791"
    environment:
      - NEXT_PUBLIC_DEPLOYMENT_URL=${NEXT_PUBLIC_DEPLOYMENT_URL:-http://127.0.0.1:3210}
      - NEXT_PUBLIC_LOAD_MONACO_INTERNALLY=${NEXT_PUBLIC_LOAD_MONACO_INTERNALLY:-}
    depends_on:
      backend:
        condition: service_healthy

volumes:
  data:

PostgreSQL (production)

yaml
services:
  backend:
    image: ghcr.io/convex/convex-backend:latest
    stop_grace_period: 10s
    stop_signal: SIGINT
    ports:
      - "3210:3210"
      - "3211:3211"
    environment:
      - INSTANCE_NAME=${INSTANCE_NAME:-convex-self-hosted}
      - INSTANCE_SECRET=${INSTANCE_SECRET}
      - CONVEX_CLOUD_ORIGIN=${CONVEX_CLOUD_ORIGIN:-http://127.0.0.1:3210}
      - CONVEX_SITE_ORIGIN=${CONVEX_SITE_ORIGIN:-http://127.0.0.1:3211}
      - POSTGRES_URL=${POSTGRES_URL}
      - DO_NOT_REQUIRE_SSL=${DO_NOT_REQUIRE_SSL:-1}
      - V8_ACTION_USER_TIMEOUT_SECS=${V8_ACTION_USER_TIMEOUT_SECS:-}
      - NODE_ACTION_USER_TIMEOUT_SECS=${NODE_ACTION_USER_TIMEOUT_SECS:-}
      - DISABLE_METRICS_ENDPOINT=${DISABLE_METRICS_ENDPOINT:-true}
      - DOCUMENT_RETENTION_DELAY=${DOCUMENT_RETENTION_DELAY:-172800}
      - RUST_LOG=${RUST_LOG:-info}
      - DISABLE_BEACON=${DISABLE_BEACON:-false}
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: curl -f http://localhost:3210/version
      interval: 5s
      start_period: 10s

  dashboard:
    image: ghcr.io/convex/convex-dashboard:latest
    stop_grace_period: 10s
    stop_signal: SIGINT
    ports:
      - "6791:6791"
    environment:
      - NEXT_PUBLIC_DEPLOYMENT_URL=${NEXT_PUBLIC_DEPLOYMENT_URL:-http://127.0.0.1:3210}
      - NEXT_PUBLIC_LOAD_MONACO_INTERNALLY=${NEXT_PUBLIC_LOAD_MONACO_INTERNALLY:-}
    depends_on:
      backend:
        condition: service_healthy

  postgres:
    image: postgres:17-alpine
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=convex_self_hosted
    volumes:
      - postgres-data:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  postgres-data:

If port 3210, 3211, or 6791 is already taken on the host, check with ss -tlnp | grep 3210. The host-side ports can be moved with the PORT, SITE_PROXY_PORT, and DASHBOARD_PORT environment variables on the backend and dashboard.

Step 4: Create the Environment File

bash
nano .env

Add your configuration:

bash
# Instance Configuration
INSTANCE_NAME=convex-self-hosted
INSTANCE_SECRET=<generate-with-openssl-rand-hex-32>

# Public URLs (update these for production)
CONVEX_CLOUD_ORIGIN=http://127.0.0.1:3210
CONVEX_SITE_ORIGIN=http://127.0.0.1:3211
NEXT_PUBLIC_DEPLOYMENT_URL=http://127.0.0.1:3210

# PostgreSQL (only if using the PostgreSQL variant)
DB_PASSWORD=<your-secure-db-password>
POSTGRES_URL=postgresql://postgres:${DB_PASSWORD}@postgres:5432
DO_NOT_REQUIRE_SSL=1

# Optional: Logging
RUST_LOG=info

# Optional: Disable telemetry beacon
DISABLE_BEACON=false

Generate the secret:

bash
openssl rand -hex 32

DO_NOT_REQUIRE_SSL=1 is for local or plain-Postgres setups. Keep SSL required (DO_NOT_REQUIRE_SSL=0) for managed Postgres over the public internet.

Step 5: Start Convex

bash
# Start services
docker compose up -d

# View logs
docker compose logs -f

# Check status
docker compose ps

Verify immediately:

bash
curl http://localhost:3210/version

You want a JSON response with the release version. docker compose ps should show both services as healthy. If the backend is stuck in a restart loop, docker compose logs backend is the first thing to read. Usual causes: a missing or malformed INSTANCE_SECRET, a Postgres URL the container cannot reach, or a port conflict.

Step 6: Set Up Reverse Proxy with Nginx

For production with custom domains, front the three ports with Nginx. Each hostname maps to exactly one backend port, and each env var points at one hostname.

api.yourdomain.comCONVEX_CLOUD_ORIGINNEXT_PUBLIC_DEPLOYMENT_URLactions.yourdomain.comCONVEX_SITE_ORIGINHTTP actionsdashboard.yourdomain.combrowser accessno env var, just DNSNginx / TraefikTLS + WebSocket upgradebackend :3210API + syncactions :3211HTTP actionsdashboard :6791convex dashboard
One hostname per port. Point each env var at the hostname, never at 127.0.0.1, once you have a public URL.
bash
sudo apt install nginx certbot python3-certbot-nginx -y
sudo nano /etc/nginx/sites-available/convex

Paste three server blocks:

nginx
# Backend API -> 3210
server {
    listen 80;
    server_name api.yourdomain.com;

    location / {
        proxy_pass http://localhost:3210;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        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;
    }
}

# HTTP actions -> 3211
server {
    listen 80;
    server_name actions.yourdomain.com;

    location / {
        proxy_pass http://localhost:3211;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        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;
    }
}

# Dashboard -> 6791
server {
    listen 80;
    server_name dashboard.yourdomain.com;

    location / {
        proxy_pass http://localhost:6791;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        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;
    }
}

Enable the site and get certificates for all three hostnames:

bash
sudo ln -s /etc/nginx/sites-available/convex /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d api.yourdomain.com -d actions.yourdomain.com -d dashboard.yourdomain.com

Update .env with the public URLs and recreate the stack:

bash
CONVEX_CLOUD_ORIGIN=https://api.yourdomain.com
CONVEX_SITE_ORIGIN=https://actions.yourdomain.com
NEXT_PUBLIC_DEPLOYMENT_URL=https://api.yourdomain.com
bash
docker compose up -d

Failure modes at this step: the dashboard loads but data never arrives, which almost always means NEXT_PUBLIC_DEPLOYMENT_URL still points at 127.0.0.1 and the browser cannot reach it. HTTP actions returning 404 usually means the 3211 vhost is missing or CONVEX_SITE_ORIGIN points at the 3210 hostname.

Step 7: Generate Admin Key

bash
# Access backend container
docker compose exec backend /bin/sh

# Navigate to convex directory and generate admin key
cd convex
./generate_admin_key.sh

# Exit container
exit

Admin Key Is Full Admin Access

The script derives the key from INSTANCE_NAME + INSTANCE_SECRET. Same secret, same key family. The key grants full admin API access, so treat it like a root password and see the Security section before you paste it anywhere.

Save the admin key securely. You will need it for your projects.

Using Convex in Your Projects

With your self-hosted Convex backend running, connect your applications. Keep the CLI current: npm install convex@latest (1.47.0 as of October 2026). Older CLIs fail against a current self-hosted backend in confusing ways.

Configure Your Project Environment

Add these two environment variables to your application’s .env.local file (do not commit this to git):

bash
CONVEX_SELF_HOSTED_URL=https://api.convex.yourdomain.com
CONVEX_SELF_HOSTED_ADMIN_KEY=convex-self-hosted|<your-admin-key>

Replace the URL with your actual backend URL (the hostname that reaches 3210) and the admin key with the one you generated earlier. The Convex CLI uses your self-hosted backend when these variables are set.

Smoke test the whole chain:

  • npx convex --version reports a recent CLI
  • CONVEX_SELF_HOSTED_URL includes the scheme (https://) and the admin key is the full string
  • npx convex deploy pushes your functions without error
  • The dashboard shows the deployed functions and any data you wrote

If npx convex commands fail, check the CLI version first, then confirm the URL has a scheme and the key is not truncated. With Postgres in the backend, docker compose logs backend should show Connected to Postgres after startup, and you should run npx convex deploy once after switching databases so functions land in the new one.

Want to build something on top of this? Build a real-time app with Astro and Convex walks through the frontend side, and deploy Astro + Convex to Vercel for production covers the hosted-frontend path.

Advanced Configuration

Using External PostgreSQL (Neon, Supabase, AWS RDS)

For managed PostgreSQL:

  1. Create a database named convex_self_hosted
  2. Get the connection string (without database name and query params)
  3. Update the environment:
bash
POSTGRES_URL=postgresql://user:[email protected]:5432
DO_NOT_REQUIRE_SSL=0

A managed-Postgres URL looks like postgresql://user:[email protected]:5432 for Neon or postgresql://user:[email protected]:5432 for RDS. Do not append /convex_self_hosted or ?sslmode=.... Convex derives the database name from INSTANCE_NAME and opens its own connection.

Same Region Required

Put your Convex backend in the same region as your PostgreSQL database. Out-of-region latency shows up directly in mutation latency.

Cost angle: Neon’s free tier is enough to start, and bundling postgres:17-alpine on the same VPS costs nothing extra. If you bundle Postgres, the backups are your problem. If you want a separate Postgres container you can inspect, run PostgreSQL and pgAdmin on Docker.

Using MySQL (and PlanetScale)

Convex has supported MySQL since February 2025. Set the MYSQL_URL environment variable:

bash
MYSQL_URL=mysql://user:[email protected]

The database must be named convex_self_hosted, same rule as PostgreSQL. PlanetScale is the documented managed-MySQL example; AWS RDS or any MySQL 8+ server works too. Same region advice applies: keep the database close to the Convex backend.

Monitoring with Prometheus

The self-hosted backend exposes a Prometheus-compatible metrics endpoint at /metrics. The official compose ships with it disabled, so set this to expose it:

bash
DISABLE_METRICS_ENDPOINT=false

Verify the scrape:

bash
curl http://localhost:3210/metrics | head

If you get a 404, the flag is still true. The endpoint gives you request counts, latency histograms, and error rates for Grafana or any Prometheus-compatible stack. For host-level monitoring alongside it, monitor your server with Beszel and Uptime Kuma.

Tuning Concurrency and Action Timeouts

The backend exposes environment variables for controlling how many queries, mutations, and actions run at the same time:

bash
APPLICATION_MAX_CONCURRENT_QUERIES=16
APPLICATION_MAX_CONCURRENT_MUTATIONS=16
APPLICATION_MAX_CONCURRENT_V8_ACTIONS=16
APPLICATION_MAX_CONCURRENT_NODE_ACTIONS=16

The default is 16 for each, which matches the cloud Free tier’s concurrent-query cap. Increase these if your server has spare CPU and memory.

Action timeouts are split by runtime:

bash
V8_ACTION_USER_TIMEOUT_SECS=1800    # V8 actions, default 1800 (30 min)
NODE_ACTION_USER_TIMEOUT_SECS=600   # Node actions, default 600 (10 min)
HTTP_SERVER_TIMEOUT_SECONDS=300     # HTTP server, default 300 (5 min)

If your actions time out, raise the matching knob. Do not leave the old ACTIONS_USER_TIMEOUT_SECS in your compose. It was removed and split into the pair above.

Configuring S3 Storage

For production file storage, offload blobs to S3 instead of the local volume:

yaml
services:
  backend:
    environment:
      # ... other vars ...
      - AWS_REGION=us-east-1
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
      - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
      - S3_STORAGE_EXPORTS_BUCKET=convex-snapshot-exports
      - S3_STORAGE_SNAPSHOT_IMPORTS_BUCKET=convex-snapshot-imports
      - S3_STORAGE_MODULES_BUCKET=convex-modules
      - S3_STORAGE_FILES_BUCKET=convex-user-files
      - S3_STORAGE_SEARCH_BUCKET=convex-search-indexes

Create the buckets in AWS S3 or use S3-compatible storage like Cloudflare R2:

bash
S3_ENDPOINT_URL=https://<account-id>.r2.cloudflarestorage.com
AWS_ACCESS_KEY_ID=<your-r2-access-key>
AWS_SECRET_ACCESS_KEY=<your-r2-secret-key>

For MinIO, DigitalOcean Spaces, and other S3-compatible stores, the compat knobs matter: AWS_S3_FORCE_PATH_STYLE=true for path-style addressing, AWS_S3_DISABLE_CHECKSUMS=true and AWS_S3_DISABLE_SSE=true for stores that reject the newer checksum and SSE headers.

Migration Between Storage Providers

If switching from SQLite to PostgreSQL or changing S3 configuration:

bash
# Export data from old backend
npx convex export --path backup.zip

# Deploy new backend with different storage
# ...

# Import data to new backend
npx convex import --replace-all backup.zip

Exports are point-in-time snapshots, so take the export after traffic stops if you need every last write.

Custom Domains for HTTP Actions

To serve HTTP actions from a custom domain:

  1. Set up DNS for actions.yourdomain.com and proxy it to port 3211 (see the Nginx config above)
  2. Configure the backend environment:
bash
CONVEX_SITE_ORIGIN=https://actions.yourdomain.com

CONVEX_SITE_ORIGIN must be the URL that reaches port 3211, not 3210. That is the most common misconfiguration in this section.

  1. In your frontend, override the site URL at build time if the generated one is wrong:
bash
CONVEX_SITE_URL=https://actions.yourdomain.com

Dashboard and Beacon Notes

Two smaller ops facts that save support tickets:

  1. The dashboard’s Monaco editor loads from a CDN by default. On a locked-down or air-gapped network set NEXT_PUBLIC_LOAD_MONACO_INTERNALLY=true so the dashboard works without outbound CDN access.
  2. The telemetry beacon is optional. Set DISABLE_BEACON=true to switch it off.

What the Beacon Sends

With the beacon enabled, the backend sends a random deployment identifier, the database migration version, the git revision, and the uptime. No data, no queries, no schema. The project is explicit about this in the repo’s Disclaimers section, which is the kind of transparency I want before leaving it on or turning it off.

Key Environment Variables Reference

Variable Default What it does
INSTANCE_NAME convex-self-hosted Instance identifier; also derives the database name
INSTANCE_SECRET (required) Root credential for admin key generation
CONVEX_CLOUD_ORIGIN http://127.0.0.1:3210 Public URL of the backend API (port 3210)
CONVEX_SITE_ORIGIN http://127.0.0.1:3211 Public URL of HTTP actions (port 3211)
NEXT_PUBLIC_DEPLOYMENT_URL http://127.0.0.1:3210 URL the browser uses to reach the backend
POSTGRES_URL (empty = SQLite) External Postgres, no db name or query params
MYSQL_URL (empty) External MySQL, db must be convex_self_hosted
DO_NOT_REQUIRE_SSL 1 in the official compose Set 0 to require TLS to the database
V8_ACTION_USER_TIMEOUT_SECS 1800 Timeout for V8 actions
NODE_ACTION_USER_TIMEOUT_SECS 600 Timeout for Node actions
HTTP_SERVER_TIMEOUT_SECONDS 300 HTTP server request timeout
APPLICATION_MAX_CONCURRENT_QUERIES 16 Concurrent query limit
APPLICATION_MAX_CONCURRENT_MUTATIONS 16 Concurrent mutation limit
APPLICATION_MAX_CONCURRENT_V8_ACTIONS 16 Concurrent V8 action limit
APPLICATION_MAX_CONCURRENT_NODE_ACTIONS 16 Concurrent Node action limit
DISABLE_METRICS_ENDPOINT true Set false to expose /metrics
DISABLE_BEACON false in most compose files Set true to disable telemetry
DOCUMENT_RETENTION_DELAY 172800 (2 days) in the official compose How long old document versions are kept
PORT / SITE_PROXY_PORT / DASHBOARD_PORT 3210 / 3211 / 6791 Host-side port overrides
NEXT_PUBLIC_LOAD_MONACO_INTERNALLY (empty) Set true for dashboard without CDN access

Maintenance and Backups

Regular Backups

For Dokploy deployments, configure automated backups through Dokploy’s interface or follow the Dokploy Backups Guide.

For Docker Compose with PostgreSQL:

bash
# Manual backup
docker compose exec postgres pg_dump -U postgres convex_self_hosted > backup-$(date +%Y%m%d).sql

# Restore backup
cat backup-20241124.sql | docker compose exec -T postgres psql -U postgres convex_self_hosted

Automated backup script (backup.sh):

bash
#!/bin/bash
BACKUP_DIR="/backups/convex"
DATE=$(date +%Y%m%d-%H%M)
mkdir -p $BACKUP_DIR

docker compose exec -T postgres pg_dump -U postgres convex_self_hosted | gzip > $BACKUP_DIR/convex-$DATE.sql.gz

# Keep only last 7 days
find $BACKUP_DIR -name "convex-*.sql.gz" -mtime +7 -delete

Make it executable and add to crontab:

bash
chmod +x backup.sh
crontab -e
# Add: 0 2 * * * /path/to/backup.sh

Application-level backup works for both SQLite and Postgres and is what you want for migrations:

bash
npx convex export --path backup.zip
npx convex env list --include-values > .env.convex

Keep both kinds. The SQL dump is for infra-level restore on the same stack. backup.zip plus .env.convex restores into any instance, including a plain SQLite box or Convex Cloud. Push both to S3 or R2 offsite (about $1-5/month) so a dead VPS is not a dead project.

Updating Convex

Do not just pull and hope. The official upgrade path is backup-first.

Before anything else:

bash
npx convex export --path backup.zip
npx convex env list --include-values > .env.convex

Pin Both Images to the Same SHA

Different versions of convex-backend and convex-dashboard are not guaranteed to be compatible. Images are tagged with latest and full 40-character commit SHAs. Releases are named precompiled-YYYY-MM-DD-<shortsha>, e.g. precompiled-2026-10-10-72ce13c on the releases page. For production:

yaml
image: ghcr.io/convex/convex-backend:72ce13c...   # full commit SHA
image: ghcr.io/convex/convex-dashboard:72ce13c... # SAME SHA

In-place upgrade (normal case):

bash
# Pin both images to the same new SHA, then
docker compose pull && docker compose up -d

# Watch migrations finish
docker compose logs -f backend
# wait for: Executing Migration N/N. MigrationComplete(N+1)

Do not cut traffic or declare the upgrade done until you see the MigrationComplete line. If the backend is mid-migration, let it finish.

Export/import upgrade (major version jumps):

  1. Stop external traffic
  2. npx convex export
  3. npx convex env list --include-values > .env.convex
  4. Upgrade the images (both to the same SHA)
  5. npx convex import --replace-all
  6. npx convex env set --force --from-file .env.convex
  7. Restore traffic

Exports are point-in-time. Your final export must happen after load stops.

Rollback: restore backup.zip with npx convex import --replace-all on the previously pinned images. With Postgres, restoring the pre-upgrade SQL dump also works. If no migration ran yet, checking out the old compose SHA pin and running docker compose up -d is enough.

Dokploy path: redeploy from the service UI. See how to update Docker Compose stacks in Dokploy for the details of tag-vs-pin updates.

Upgrade checklist:

  • Pre-upgrade backup.zip exported and verified
  • .env.convex saved
  • Both images pinned to the same new SHA
  • MigrationComplete log line seen after startup
  • Smoke test passes (dashboard, one query, one mutation)

Clearing Data / Resetting an Instance

This Destroys Data

Back up first. Double-check CONVEX_SELF_HOSTED_URL points at the deployment you intend to wipe, not at production.

There is intentionally no destructive reset command. Clearing data means importing an empty snapshot into each table:

bash
# List tables
npx convex data

# Clear one table
npx convex import --table $tableName --replace --format jsonLines /dev/null -y

Loop that over the table names from npx convex data. For a full rebuild, destroying the volume or the Postgres database and re-running npx convex deploy is usually cleaner than clearing table by table.

Security Best Practices

  • INSTANCE_SECRET is the root credential: losing it means no new admin keys; rotating it invalidates every existing admin key. Store it in your password manager and backups. See Docker Compose secrets and secure alternatives for better patterns than a plaintext .env
  • Admin key is full admin API access: treat it like a root password, scope nothing with it, and never ship it in frontend code
  • HTTPS only: TLS on all public hostnames
  • Close the backend ports: once the proxy works, only 80 and 443 should be open. Block 3210, 3211, and 6791 at the firewall
  • Strong database passwords: complex passwords for PostgreSQL and MySQL, even on a private Docker network
  • Regular updates: keep Convex, Docker, and system packages updated with the backup-first upgrade procedure above
  • Backup encryption: encrypt database and export backups at rest, especially if they land in S3
  • Environment files stay out of git: .env and .env.local never get committed
  • Rotate admin keys deliberately: only when you can update every app’s .env.local in the same window
  • Network isolation: use Docker networks to isolate services from unrelated containers on the box
  • Monitor logs and ports: set up log monitoring and alerting on the exposed surface

Rotating INSTANCE_SECRET is a maintenance event, not a casual task. Every admin key derived from the old secret breaks, so you regenerate with generate_admin_key.sh and update every app’s .env.local in the same window. For the host-level firewall and intrusion detection side, secure your VPS with CrowdSec.

Troubleshooting Common Problems

Symptom Likely cause Fix
docker pull ghcr.io/get-convex/... denied or not found Image namespace moved Use ghcr.io/convex/convex-backend and ghcr.io/convex/convex-dashboard
Dashboard loads but queries hang NEXT_PUBLIC_DEPLOYMENT_URL points at 127.0.0.1 Set it to the URL the browser can reach (your api. hostname)
Backend restart loop Bad INSTANCE_SECRET, unreachable Postgres, or port conflict docker compose logs backend; check ss -tlnp | grep 3210
HTTP actions 404 No vhost for port 3211, or CONVEX_SITE_ORIGIN points at 3210 Add the actions. server block and point CONVEX_SITE_ORIGIN at it
No Connected to Postgres in logs Wrong POSTGRES_URL shape, wrong db name, or SSL requirement No db name/query params; db named convex_self_hosted; DO_NOT_REQUIRE_SSL=1 for plain local Postgres
Actions time out early Old or default timeout knobs Set V8_ACTION_USER_TIMEOUT_SECS, NODE_ACTION_USER_TIMEOUT_SECS, HTTP_SERVER_TIMEOUT_SECONDS
/metrics returns 404 Metrics endpoint disabled by default Set DISABLE_METRICS_ENDPOINT=false
Dashboard editor will not load offline Monaco loads from a CDN Set NEXT_PUBLIC_LOAD_MONACO_INTERNALLY=true

If none of these match, the Convex Discord #self-hosted channel is active and worth asking in.

Conclusion

Self-hosting Convex gives you control over your real-time backend infrastructure while keeping Convex’s developer experience. Whether you use Dokploy or Docker Compose, you can have a production-ready Convex deployment in a session. Convex handles real-time queries, serverless functions, file storage, and search. Self-hosting adds infrastructure control to those features.

Convex open-sourced its backend in November 2025 and raised a $57M Series B led by Insight Partners in August 2026. The project is actively developed, and the self-hosted build tracks the cloud code within a handful of days. That is the freshness argument for self-hosting: you are not betting on a side project.

For smaller applications, SQLite works well with minimal resources. When you need to scale, move to PostgreSQL or MySQL, pin your image SHAs, and keep backups offsite.

Next Steps

Learn More About Convex

Questions about self-hosting Convex? Leave a comment below.

Frequently Asked Questions

Should I use SQLite or PostgreSQL?

SQLite works well for:

  • Development and testing
  • Small to medium applications (under 10k requests/day)
  • Single-server deployments
  • Prototypes

PostgreSQL is better when:

  • You have production workloads with high traffic
  • You want managed database features and replication
  • You use managed database services (Neon, Supabase, AWS RDS)

Start with SQLite and move to PostgreSQL when you need more reliability. The export/import flow makes that move boring, which is what you want.

Can I migrate from cloud-hosted Convex to self-hosted?

Yes. The process is export and import:

  1. Export data from cloud: npx convex export --prod
  2. Set up the self-hosted backend
  3. Import data: npx convex import --replace-all
  4. Update environment variables in your frontend
  5. Redeploy functions: npx convex deploy

Your application code does not change. Only the backend URL and admin key change.

How much does self-hosting Convex cost?

Monthly costs (example):

  • VPS with 4GB RAM (Hetzner-class): $5-10/month
  • PostgreSQL on Neon: free tier, or bundled postgres:17-alpine on the same box for $0
  • Domain: about $1/month
  • S3 storage (optional): about $1-5/month

Total: $10-30/month all-in.

Compare that with Convex Professional at $25 per developer per month. For a solo operator, self-hosting wins on cost if your time is free. For a team, the managed product is often cheaper than the support hours. Numbers from an actual load test are in our self-hosted Convex vs cloud benchmarks.

Can I use self-hosted Convex in production?

Yes. Make sure to:

  • Use PostgreSQL or MySQL instead of SQLite
  • Set up automated backups (SQL dump plus npx convex export)
  • Configure monitoring
  • Use SSL/TLS
  • Pin backend and dashboard images to the same SHA
  • Use the backup-first upgrade procedure from the Maintenance section
  • Run in a reliable hosting environment

The production guidelines in this article cover the rest.

Does self-hosted Convex support all cloud features?

Self-hosted Convex supports all the free-tier features of the cloud product: real-time queries and mutations, serverless functions, file storage, scheduled functions, full-text search, vector search, and HTTP actions. The cloud product is optimized for scale. You handle infrastructure management: backups, scaling, and maintenance.

How do I scale self-hosted Convex?

Scale vertically:

  • Increase VPS resources (CPU/RAM)
  • Move to a larger managed PostgreSQL instance
  • Offload files to S3

There is no official multi-instance story for the self-hosted backend. It is a single stateful service, so do not put several backends behind a load balancer. Run a bigger box and let Postgres do the heavy lifting. If you outgrow one node, the managed product is the next step.

Can I use Convex Auth with self-hosted?

Convex Auth works with self-hosted deployments. Follow the manual setup instructions in the Convex Auth documentation. The CLI’s automatic setup does not support self-hosted yet.

What happens if my backend goes down?

With a proper setup:

  • Docker restarts crashed containers
  • SQLite data persists in the volume, Postgres data in its volume
  • Real-time subscriptions reconnect automatically
  • Recent operations may need to be retried by clients

For high availability:

  • Monitor with Beszel and Uptime Kuma
  • Keep PostgreSQL on a managed service with replication if you need it
  • Keep automated backups and a documented restore path

A single VPS is a single point of failure. Budget for that instead of pretending otherwise.

Did this guide work for you?

Need help with Astro, VPS, or a self-hosted app? View services →