Log inSign up

A private Supabase stack on one server

Clone the Supabase repository, copy its docker folder into a project directory, replace every secret in .env (database password, JWT secret, anon and service keys, Studio login) and start the stack with docker compose up -d. Bind the Kong gateway on port 8000 and the pooler to loopback, then publish https://db.example.net through Caddy.

Topic: Self-hosted apps · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What does the Supabase stack contain and what does it need?

The Compose file starts PostgreSQL, the Kong API gateway, GoTrue for auth, PostgREST, Realtime, Storage with an image proxy, Edge Functions, Postgres Meta, the Studio dashboard, an analytics service and the Supavisor pooler. That is a dozen containers, so plan for at least 4 GB of RAM and 2 vCPU; 8 GB is comfortable for real projects.

  • Ubuntu 24.04/22.04, Debian 12/13, Rocky Linux 9 or AlmaLinux 9.
  • Docker Engine with Compose (see Docker Engine or the Docker app image) and git.
  • A hostname such as db.example.net pointing to 198.51.100.24.

How do you fetch the Docker files?

The official files live in the docker folder of the Supabase repository. Copy them to a separate project folder so a later git pull never overwrites your settings.

cd /opt
sudo git clone --depth 1 https://github.com/supabase/supabase
sudo mkdir supabase-project && sudo chown deploy:deploy supabase-project
cp -rf supabase/docker/* supabase-project
cp supabase/docker/.env.example supabase-project/.env
cd supabase-project
docker compose pull

Which secrets must you change before the first start?

The example .env ships with public demo values; anyone who knows them could read your data, so replace all of them before starting:

  • POSTGRES_PASSWORD: letters and digits only, for example from openssl rand -hex 20.
  • JWT_SECRET: at least 32 characters; every API key is signed with it.
  • ANON_KEY and SERVICE_ROLE_KEY: JWTs signed with your new secret, carrying the roles anon and service_role.
  • DASHBOARD_USERNAME and DASHBOARD_PASSWORD: the basic-auth login for Studio.
  • SECRET_KEY_BASE, VAULT_ENC_KEY (32 characters), the analytics tokens and POOLER_TENANT_ID.

Recent copies of the docker folder include a key helper under utils/; if yours has one, run it to fill these fields. Otherwise use the key generator on the Supabase self-hosting page with your own JWT secret. Then set the public URLs:

SITE_URL=https://app.example.net
API_EXTERNAL_URL=https://db.example.net
SUPABASE_PUBLIC_URL=https://db.example.net

How do you keep the gateway and database off the public internet?

Docker writes its own firewall rules, so ports published on 0.0.0.0 stay reachable even with ufw or firewalld active. Edit docker-compose.yml and prefix the published ports with loopback. For Kong:

    ports:
      - 127.0.0.1:${KONG_HTTP_PORT}:8000/tcp
      - 127.0.0.1:${KONG_HTTPS_PORT}:8443/tcp

Do the same for the pooler (Supavisor) entries for ${POSTGRES_PORT} and ${POOLER_PROXY_PORT_TRANSACTION}. If an outside service needs PostgreSQL, allow only its IP rather than publishing the port to everyone; remote database access explains the safer patterns.

How do you start the stack and confirm it works?

docker compose up -d
docker compose ps
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:8000/rest/v1/ -H "apikey: PASTE_ANON_KEY"

Wait until docker compose ps marks the services as healthy; the first start initialises the database and can take a couple of minutes. A 200 from the REST endpoint proves Kong, PostgREST and your new keys line up. A 401 means the key was not signed with the current JWT_SECRET.

How do you add HTTPS with Caddy?

Kong speaks plain HTTP on loopback, and Caddy terminates TLS in front of it, including the websockets used by Realtime. Install Caddy (see Caddy HTTPS) and add:

db.example.net {
    reverse_proxy 127.0.0.1:8000
}
sudo systemctl reload caddy
sudo ufw allow 80,443/tcp            # Ubuntu, Debian
sudo firewall-cmd --permanent --add-service=https --add-service=http \
  && sudo firewall-cmd --reload     # Rocky, Alma

Studio now opens at https://db.example.net behind the dashboard username and password. Client libraries use the same URL together with the anon key.

How do you configure auth emails?

GoTrue sends confirmation, magic-link and password-reset messages. Fill in the SMTP block in .env with an authenticated relay on port 587:

SMTP_ADMIN_EMAIL=admin@example.net
SMTP_HOST=smtp.relay.example.net
SMTP_PORT=587
SMTP_USER=relay-user
SMTP_PASS=relay-password
SMTP_SENDER_NAME=Example App
ENABLE_EMAIL_AUTOCONFIRM=false

Apply it with docker compose up -d. Treat port 25 as unavailable unless support confirms otherwise by ticket; the relay route in SMTP relay for apps is what keeps auth mail out of spam folders. Set DISABLE_SIGNUP=true if only invited users should get accounts.

How do you back up and upgrade a self-hosted Supabase?

Dump the database and archive the storage folder on a schedule:

cd /opt/supabase-project
docker compose exec -T db pg_dump -U postgres -d postgres | gzip > ~/supabase-$(date +%F).sql.gz
sudo tar czf ~/supabase-storage-$(date +%F).tar.gz volumes/storage

For upgrades, update the cloned repository with git -C /opt/supabase pull, compare its docker/docker-compose.yml and .env.example with your copies (diff shows new services and variables), carry over the new image tags while keeping your loopback port edits, then run docker compose pull and docker compose up -d. The PostgreSQL backup guide covers restoring a dump.

What causes most self-hosting problems?

  • Containers restart in a loop: usually memory; check docker stats and move to a larger plan if the total sits near the limit.
  • Studio login fails: Kong reads DASHBOARD_* only at start, so recreate it after changes.
  • Changed the database password later: POSTGRES_PASSWORD is applied only on first initialisation; changing it afterwards needs an ALTER ROLE inside PostgreSQL for each service role as well.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A4-8a production project with moderate traffic4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months
A4-12heavier realtime and storage use4 vCPU, 12 GB RAM, 260 GB NVMe$43.20/mo$43.20 for 1 month

Questions about Self-hosted Supabase

Is self-hosted Supabase the same as the hosted platform?

The core services are the same open-source projects. Some platform features, such as multiple projects in one dashboard and managed backups, are not part of the Docker stack; one stack serves one project.

Can I run several Supabase projects on one server?

Each project needs its own copy of the stack with distinct ports and secrets. That multiplies memory use, so larger plans suit it better.

Do I need the analytics container?

Studio uses it for logs. It can be removed by editing the Compose file, but follow the self-hosting docs so dependent services do not fail to start.

How do I connect with psql?

Through the pooler on port 5432 with the user postgres. followed by your tenant ID, from the server itself or over an SSH tunnel while the port stays on loopback.

Where are uploaded files kept?

Storage writes to volumes/storage in the project folder by default, on the local disk of the server. Back it up together with the database dump.