On this page
- What does the Supabase stack contain and what does it need?
- How do you fetch the Docker files?
- Which secrets must you change before the first start?
- How do you keep the gateway and database off the public internet?
- How do you start the stack and confirm it works?
- How do you add HTTPS with Caddy?
- How do you configure auth emails?
- How do you back up and upgrade a self-hosted Supabase?
- What causes most self-hosting problems?
- Questions
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.netpointing to198.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 pullWhich 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 fromopenssl rand -hex 20.JWT_SECRET: at least 32 characters; every API key is signed with it.ANON_KEYandSERVICE_ROLE_KEY: JWTs signed with your new secret, carrying the rolesanonandservice_role.DASHBOARD_USERNAMEandDASHBOARD_PASSWORD: the basic-auth login for Studio.SECRET_KEY_BASE,VAULT_ENC_KEY(32 characters), the analytics tokens andPOOLER_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.netHow 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/tcpDo 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, AlmaStudio 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=falseApply 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/storageFor 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 statsand 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_PASSWORDis applied only on first initialisation; changing it afterwards needs anALTER ROLEinside 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.
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.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM