How to Self-Host Supabase on Ubuntu 24.04 with Docker Compose

Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer
IntermediateUpdated Nov 17, 202629 min read~45+ minutes total
SupabaseDocker ComposeUbuntu 24.04PostgreSQLSelf-HostingCaddyBackupSecurity
Last reviewed:
Tutorial
How to Self-Host Supabase on Ubuntu 24.04 with Docker Compose
rafftechnologies.com/learn
On this page

Prerequisites

  • An Ubuntu 24.04 VM with SSH sudo access, at least 2 CPU cores / 4 GB RAM / 40 GB SSD for the full default stack, a domain pointed to the VM, ports 80/443 available, a tested recovery path, and an off-server backup destination

Run your own Supabase, with your Postgres data on your own server.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month

  1. 1Pick a Linux imageUbuntu, Debian and more, with your SSH key added.
  2. 2Choose a sizeFrom $4.99 a month. Resize when your app grows.
  3. 3Connect over SSHYour server is up in about 55 seconds.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

Self-hosting Supabase on Ubuntu 24.04 gives you PostgreSQL, Auth, Storage, Realtime, Studio, the REST API, and supporting services on infrastructure you operate yourself. The current supported deployment path is Supabase's version-tracked Docker Compose bundle, not a hand-built collection of unrelated container tags.

The saved test environment used a Raff Linux VM as its Ubuntu 24.04 host. The existing test note remains Ubuntu 24.04 LTS on Raff 2 vCPU / 4 GB RAM VM (existing tested environment; current Supabase minimum). This revision re-verifies the procedure against Supabase's current self-hosting, HTTPS, and update documentation without claiming a fresh end-to-end machine test.

Supabase currently documents 2 CPU cores, 4 GB RAM, and 40 GB SSD as the minimum for the full default stack, with 4 cores, 8 GB+ RAM, and 80 GB+ SSD recommended. The current manual-install documentation shows the stable self-hosted configuration snapshot self-hosted/v0.8.0; the Linux quick-start records whichever current snapshot it installs in .supabase-version. Keep that file: the supported update.sh workflow uses it as the merge base for future updates.

Self-hosting also moves operational responsibility to you. Supabase's update tooling backs up configuration, but it does not back up Postgres or Storage data. This tutorial therefore treats the database, Storage objects, .env, keys, and versioned configuration as one recovery plan.

Prerequisites:

  • Ubuntu 24.04 with SSH and sudo access
  • At least 2 CPU cores, 4 GB RAM, and 40 GB SSD for the full default stack
  • A domain such as supabase.example.com pointing to the VM
  • Public TCP 80 and 443 available for HTTPS
  • A tested recovery path before firewall or upgrade changes
  • An off-server destination for backups

Step 1 — Verify Ubuntu, resources, DNS, and existing listeners

Confirm the operating system and architecture:

Bash
cat /etc/os-release uname -m

Check CPU, memory, and storage:

Bash
nproc free -h df -h / lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINTS

Set your public Supabase hostname and verify DNS:

Bash
export SUPABASE_DOMAIN=supabase.example.com dig +short A "$SUPABASE_DOMAIN" dig +short AAAA "$SUPABASE_DOMAIN"

Only publish an AAAA record if IPv6 really reaches this server and is protected consistently.

Inspect current listeners:

Bash
sudo ss -tulpn

Ports 80 and 443 must be available for the HTTPS reverse proxy. Do not continue with the full default stack if the server is below Supabase's documented minimum.

Verify: Ubuntu should report 24.04, the VM should meet the current minimum, DNS should point to this server, and no unexpected service should already own TCP 80 or 443.

Step 2 — Install prerequisites and inspect Supabase's official setup script

Install the utilities used by the current Linux quick-start:

Bash
sudo apt update sudo apt install -y ca-certificates curl git openssl jq dnsutils

Download the official setup script to a file instead of piping it directly into a shell:

Bash
curl -fsSL https://supabase.link/setup.sh -o setup.sh

Inspect it before execution:

Bash
sed -n '1,220p' setup.sh

Supabase documents this script as the Linux quick-start for Debian/Ubuntu and related supported distributions. It can install Docker Engine when needed, fetch the versioned Docker configuration, generate secrets and API keys, prompt for public URLs, record the installed release, and pull the tested image set.

Check the file exists and is not empty:

Bash
test -s setup.sh && echo 'Supabase setup script downloaded'

Verify: setup.sh should be present locally and reviewed before you run it; do not execute an uninspected remote shell pipeline as part of a production deployment.

Step 3 — Run the version-tracked Supabase Linux setup

Run the downloaded script:

Bash
sh setup.sh

When prompted, use your actual deployment URLs. A common layout is:

Text
SUPABASE_PUBLIC_URL=https://supabase.example.com API_EXTERNAL_URL=https://supabase.example.com/auth/v1 PROXY_DOMAIN=supabase.example.com SITE_URL=https://app.example.com

SITE_URL is the URL of your own frontend application where users land after authentication; it is not necessarily the Supabase host.

The quick-start normally creates supabase-project in the current directory. Enter it and inspect the generated files:

Bash
cd supabase-project ls -la cat .supabase-version

Current new installations record their release in .supabase-version. Supabase's current manual-install documentation shows self-hosted/v0.8.0 as the stable snapshot at this revision, but always trust the value actually recorded by the installer you ran.

Verify: The project should contain .env, docker-compose.yml, run.sh, update.sh on current bundles, and .supabase-version; the version file must not be empty.

Step 4 — Review generated secrets, API keys, and URL roles

Display generated credentials only in a private administrator session:

Bash
sh run.sh secrets

Review .env locally:

Bash
nano .env

Confirm the public URL values:

Text
SUPABASE_PUBLIC_URL=https://supabase.example.com API_EXTERNAL_URL=https://supabase.example.com/auth/v1 SITE_URL=https://app.example.com PROXY_DOMAIN=supabase.example.com

Confirm that a non-default DASHBOARD_PASSWORD exists. Current Supabase setup also generates newer publishable/secret API keys alongside legacy anon/service-role compatibility values.

Never expose server-side secret keys or service-role credentials in browser code, public repositories, screenshots, logs, or support tickets.

Search for obvious placeholders without printing the real secrets:

Bash
grep -nE 'CHANGE_ME|your-super-secret|your-tenant-id|your-domain' .env || true

Review every returned line before continuing.

Verify: Public URLs should match the real deployment, the dashboard password should be generated rather than default, and no secret placeholder should remain unresolved.

Step 5 — Protect .env and prepare the firewall without locking out SSH

Restrict the environment file:

Bash
chmod 600 .env stat -c '%a %n' .env

Keep a protected off-server copy of .env and any generated signing-key material; these values are part of the recovery plan.

Check UFW before changing firewall state:

Bash
sudo ufw status numbered

If UFW is already active, verify the real SSH rule and allow HTTPS traffic:

Bash
sudo ufw allow 80/tcp comment 'Supabase HTTP/ACME' sudo ufw allow 443/tcp comment 'Supabase HTTPS' sudo ufw status numbered

If UFW is inactive, do not blindly enable it from a single SSH session. Use the lockout-safe flow in Set Up UFW Firewall on Ubuntu 24.04.

Do not expose internal Postgres, Supavisor, API-gateway, Studio, or service ports to the public internet unless you have an explicit network design for them.

Verify: .env should be mode 600, SSH should remain reachable, and only the public ports intentionally required by the deployment should be exposed.

Step 6 — Start Supabase and verify container health

Start the versioned stack:

Bash
cd supabase-project sh run.sh start

Supabase's current helper wraps Docker Compose startup and waits for health checks.

Inspect service state:

Bash
docker compose ps

If one or more services do not become healthy, run the bundled diagnostics:

Bash
sh tests/test-container-logs.sh

Inspect a specific service when needed:

Bash
sh run.sh logs storage

Do not fix a health problem by independently upgrading one random container image. Supabase publishes tested self-hosted snapshots because the services are expected to work together.

Verify: Required containers should be Up and healthy; unresolved restart loops or unhealthy services must be fixed before enabling public traffic.

Step 7 — Enable Supabase's Caddy HTTPS override

Supabase's current production guidance requires HTTPS and provides a preconfigured Caddy override.

Confirm DNS first:

Bash
SUPABASE_DOMAIN=supabase.example.com dig +short A "$SUPABASE_DOMAIN"

Enable the Caddy override and start the stack:

Bash
cd supabase-project sh run.sh config add caddy sh run.sh start

The bundled proxy terminates TLS in front of the Supabase API gateway and handles WebSocket upgrades required by Realtime.

Check the Caddy service if certificate issuance fails:

Bash
docker logs supabase-caddy --tail=100

Verify: Caddy should remain running, obtain a trusted certificate for the real domain, and ports 80/443 should be the intended public ingress path.

Step 8 — Verify HTTPS, Auth, Studio, and the API gateway

Test the public Auth route:

Bash
curl -I https://supabase.example.com/auth/v1/

Supabase's HTTPS documentation uses a 401 response here as proof that the request reached Auth through the secure reverse proxy.

Open Studio:

Text
https://supabase.example.com

Sign in with the generated dashboard credentials.

Then test the REST gateway:

Bash
curl -I https://supabase.example.com/rest/v1/

An unauthenticated REST request may be rejected; the important check is that the public HTTPS gateway responds and does not require direct access to internal container ports.

In Studio, confirm the Database, Authentication, Storage, and Realtime areas load without service errors.

Verify: HTTPS should be trusted, Auth should respond through the public domain, Studio should accept the generated credentials, and the REST gateway should be reachable over the same HTTPS hostname.

Step 9 — Create a small end-to-end database and API test

Use Studio's SQL editor to create a disposable table:

Sql
create table if not exists public.raff_supabase_test ( id bigint generated by default as identity primary key, note text not null, created_at timestamptz not null default now() ); insert into public.raff_supabase_test (note) values ('self-hosted Supabase verification'); select * from public.raff_supabase_test;

This confirms the database is writable through the application stack.

If you test the REST API from a client, use the generated publishable client key or the compatibility anon key according to the current application integration you are validating. Do not put the secret/server-side or service-role credential into a browser test.

After validation, remove the disposable table:

Sql
drop table if exists public.raff_supabase_test;

Verify: The row should be created and readable in Studio, and the disposable table should be removed after the test.

Step 10 — Understand Postgres access before exposing any database port

Self-hosted Supabase currently uses Supavisor as the default connection pooler. Supabase documents session mode on port 5432 and transaction mode on port 6543 for different client patterns.

Do not interpret those ports as a recommendation to make them public. For application servers on the same private network, prefer private connectivity and firewall rules that allow only the intended source systems.

Check the compose model before creating any external database rule:

Bash
cd supabase-project docker compose config | grep -nE '5432|6543|8000' | head -n 40

If a remote database client is genuinely required, use the connection mode that matches the workload and restrict the source network explicitly. For general internet-facing application traffic, use the HTTPS API gateway rather than exposing Postgres broadly.

Verify: There should be no accidental public database exposure; any 5432/6543 access should be intentional, source-restricted, and tied to a known client requirement.

Step 11 — Back up Postgres, Storage objects, configuration, and version metadata

Supabase's update.sh backs up configuration files, but the current documentation explicitly states that it does not back up Postgres or Storage data. Create your own recovery set before upgrades and before important production changes.

Create a protected backup directory:

Bash
cd supabase-project mkdir -p backups/manual chmod 700 backups/manual STAMP="$(date -u +%Y%m%d-%H%M%S)"

For a logically recoverable database copy, preserve roles and the main Postgres database separately:

Bash
docker compose exec -T db \ pg_dumpall -U postgres --roles-only \ | gzip > "backups/manual/roles-${STAMP}.sql.gz" docker compose exec -T db \ pg_dump -U postgres -d postgres -Fc \ > "backups/manual/postgres-${STAMP}.dump"

If Storage is in use, coordinate a maintenance window or otherwise stop application writes while the database dump and Storage copy are taken so that database metadata and object files do not drift apart.

Archive the self-hosted Storage data directory used by the official Docker bundle:

Bash
tar -czf "backups/manual/storage-${STAMP}.tar.gz" \ volumes/storage

Archive the sensitive configuration and recorded release:

Bash
tar -czf "backups/manual/config-${STAMP}.tar.gz" \ .env .supabase-version docker-compose.yml run.sh update.sh volumes/proxy 2>/dev/null || \ tar -czf "backups/manual/config-${STAMP}.tar.gz" \ .env .supabase-version docker-compose.yml run.sh volumes/proxy chmod 600 backups/manual/*

Validate the artifacts:

Bash
gzip -t "backups/manual/roles-${STAMP}.sql.gz" pg_restore -l "backups/manual/postgres-${STAMP}.dump" | head tar -tzf "backups/manual/storage-${STAMP}.tar.gz" | head tar -tzf "backups/manual/config-${STAMP}.tar.gz" | head

Copy the complete recovery set off the VM. Raff Object Storage can be an off-server target for S3-compatible backup tooling, while Data Protection can provide an additional VM-level recovery layer.

Verify: Roles, database, Storage, and configuration archives should all be readable, protected, and copied to a separate failure domain.

Step 12 — Rehearse a restore on an isolated test VM

Do not prove backups by overwriting production. Use a disposable VM or isolated recovery project.

Start from the same self-hosted release recorded in the backup's .supabase-version. Restore the configuration bundle, then keep application services stopped while you prepare the database.

A same-version recovery pattern is:

Bash
cd supabase-project docker compose up -d db

Restore roles:

Bash
gunzip -c /backup/roles-YYYYMMDD-HHMMSS.sql.gz \ | docker compose exec -T db psql -U postgres -d postgres

Restore the custom-format database dump into the disposable database service:

Bash
docker compose exec -T db \ pg_restore -U postgres -d postgres --clean --if-exists \ < /backup/postgres-YYYYMMDD-HHMMSS.dump

Restore the matching Storage archive into the recovery project before starting Storage/API services:

Bash
tar -xzf /backup/storage-YYYYMMDD-HHMMSS.tar.gz -C .

Then start the stack:

Bash
sh run.sh start

Validate Studio login, representative database rows, Auth users relevant to the test, and several Storage objects. Keep SMTP, OAuth callbacks, webhooks, and other external integrations disabled or redirected in a recovery rehearsal so the test copy cannot trigger production side effects.

A logical database restore can be sensitive to major-version or self-hosted service differences. That is why the first recovery test should use the exact recorded self-hosted snapshot and why upgrades need a fresh backup after successful verification.

Verify: The isolated instance should boot on the intended self-hosted release, Studio should work, representative data and Storage objects should be present, and no production integration should be triggered from the test environment.

Step 13 — Update Supabase with the supported version-tracked workflow

Check the installed base version:

Bash
cd supabase-project cat .supabase-version

Create the full recovery set from Step 11 before applying an update.

Preview the current update first:

Bash
sh update.sh --dry-run

The dry run is most useful when .supabase-version records the deployment's real base version. Review breaking-change notices, new .env keys, and any merge conflicts.

Apply the configuration update:

Bash
sh update.sh

Then pull the tested image set and recreate the containers:

Bash
sh run.sh pull sh run.sh recreate

Check the new recorded version and service health:

Bash
cat .supabase-version docker compose ps

Do not assume update.sh protects application data: Supabase explicitly separates configuration backup from Postgres and Storage backup responsibilities.

Verify: The update should complete without unresolved merge conflicts, .supabase-version should advance to the intended release, and every required service should return to healthy state.

Step 14 — Run the final security, recovery, and exposure audit

Check service health and the recorded release:

Bash
cd supabase-project cat .supabase-version docker compose ps

Check public HTTPS:

Bash
curl -I https://supabase.example.com/auth/v1/ curl -I https://supabase.example.com/rest/v1/

Inspect host listeners and firewall rules:

Bash
sudo ss -tulpn sudo ufw status numbered

Confirm all of the following:

  • Ubuntu meets the resources required by the services you enabled;
  • the deployment has a non-empty .supabase-version;
  • the self-hosted services are running as one reviewed snapshot rather than arbitrary image versions;
  • .env is mode 600 and protected off-server;
  • dashboard credentials are non-default;
  • secret/server-side and service-role keys are not present in frontend code;
  • HTTPS terminates at the intended reverse proxy;
  • Realtime traffic can pass through the proxy's WebSocket support;
  • internal database and API-gateway ports are not unintentionally public;
  • Postgres and Storage data are backed up separately from the configuration backup created by update.sh;
  • the recovery set includes .env, signing material, version metadata, database roles, database contents, and Storage objects;
  • at least one restore has been rehearsed on an isolated instance;
  • a new full backup exists after any successful upgrade.

Verify: There should be no unhealthy service, default credential, exposed secret, accidental public database listener, missing Storage backup, or untested recovery path.

Troubleshooting

One or more containers never become healthy

Run the bundled diagnostics:

Bash
cd supabase-project sh tests/test-container-logs.sh sh run.sh logs storage

Also confirm the server still meets the documented CPU, RAM, and disk minimum.

HTTPS returns certificate or proxy errors

Check DNS and Caddy:

Bash
dig +short A supabase.example.com docker logs supabase-caddy --tail=200 sudo ss -lntp | grep -E ':(80|443)\b'

The domain must resolve to the server and public 80/443 must reach the reverse proxy.

OAuth redirects use the wrong URL

Review the URL roles in .env:

Text
SUPABASE_PUBLIC_URL=https://supabase.example.com API_EXTERNAL_URL=https://supabase.example.com/auth/v1 SITE_URL=https://app.example.com

SITE_URL is the application users return to, not automatically the Supabase host.

Studio works but frontend requests fail

Review the generated credentials:

Bash
sh run.sh secrets

Use a publishable/anon client credential where appropriate and keep secret/service-role credentials on trusted backend systems only. Also check browser/network responses through the public HTTPS gateway rather than testing an internal container URL.

update.sh --dry-run cannot show a meaningful diff

Check .supabase-version:

Bash
cat .supabase-version

Supabase documents that update merging needs a recorded base version. Older untracked installations require you to establish the correct base before a full three-way update preview can work safely.

An update succeeded but data is missing

Do not rely on update.sh configuration backups as a database recovery mechanism. Restore from the independent Postgres and Storage recovery set created before the update, on an isolated instance first if possible.

A restore starts but Storage objects are missing

The Postgres dump contains Storage metadata but not the object files themselves. Restore the matching volumes/storage archive as well as the database and configuration recovery set.

Conclusion

You now have a current Supabase self-hosting workflow for Ubuntu 24.04 using Supabase's version-tracked Docker Compose bundle, generated credentials, Caddy HTTPS, health checks, private database exposure, a real database/API verification, independent Postgres and Storage backups, isolated restore testing, and the supported update.sh upgrade path.

The most important operational rule is to keep the deployment as a coordinated self-hosted snapshot and to separate configuration updates from data protection. .supabase-version tells the updater what configuration you started from; it does not replace database, Storage, secret, or recovery backups.

For adjacent host setup and security work, see Install Docker on Ubuntu 24.04 and Harden Ubuntu 24.04.

Deploy a Raff Ubuntu VM for the self-hosted Supabase stack. Size the host for PostgreSQL, Auth, Storage, and Realtime, and maintain independent backups of data and configuration.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month · 14-day money-back guarantee

Deploy Your Server
Was this article helpful?
Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer

Aybars is a Platform Engineer & Technical Writer at Raff Technologies. He works on Linux VM templates, self-hosted application workflows, and security-focused deployment validation, turning tested infrastructure procedures into clear, practical tutorials for developers and teams.

Run your own Supabase, with your Postgres data on your own server.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

14-day money-back guarantee

Frequently asked questions

What are the minimum server requirements for self-hosted Supabase?
Supabase currently documents 2 CPU cores, 4 GB RAM, and 40 GB SSD as the minimum for the full default stack, with 4 cores, 8 GB+ RAM, and 80 GB+ SSD recommended. Removing unused services can reduce requirements.
What self-hosted Supabase version should I install?
Use the version-tracked self-hosted Docker snapshot distributed by Supabase rather than independently choosing every service image. The current manual documentation shows `self-hosted/v0.8.0`; quick-start installs record the actual release in `.supabase-version`.
Why is `.supabase-version` important?
Supabase's `update.sh` uses the recorded base release for its three-way merge. Without a correct base version, a dry run cannot reliably identify changes and conflicts in existing files.
Does self-hosted Supabase require HTTPS?
Supabase's current production guidance requires HTTPS. The official Docker bundle includes Caddy and Nginx reverse-proxy options; this tutorial uses the Caddy override for automatic TLS and WebSocket support.
Which Supabase key should frontend code use?
Use a publishable client key or the compatibility anon key when appropriate. Never expose the secret/server-side key or service-role credential in browser code because those credentials have elevated access.
Does `update.sh` back up the Supabase database?
No. Supabase explicitly states that `update.sh` backs up configuration but does not back up Postgres or Storage data. Create independent database, Storage, secret, and configuration recovery copies before updates.
What should a self-hosted Supabase backup include?
Protect database roles, the Postgres database, Storage object files, `.env`, signing/API key material, `.supabase-version`, and the Docker/proxy configuration. Keep at least one complete set off-server and test a restore.
Should I expose Supabase Postgres directly to the internet?
Not by default. Self-hosted Supabase supports Supavisor session and transaction modes, but remote database access should be private or tightly source-restricted. Normal application traffic should usually use the HTTPS API gateway.

Related Articles

View all →