New - NVIDIA B200 & B300 Dedicated GPU Clusters  |  Explore GPU clusters

Self-Host Supabase on a VPS with Docker: Production Setup

Posted on 25.11.2026

Supabase’s self-hosting guide gets you a running stack in about ten minutes. Every container reports healthy, the dashboard loads, and the REST API answers requests, so the stack looks ready for production traffic.

However, when you look closely, the shipped .env carries a JWT secret published in the documentation, a dashboard password that reads this_password_is_insecure_and_should_be_updated, an API gateway bound to port 8000 on every interface, an SMTP host pointing at a mail container the compose file no longer includes, no memory limits on any service, and a Postgres instance running on whatever the image defaults to. Each one becomes a real problem the first time the deployment faces the internet.

This walkthrough starts from the official compose files and closes those items one at a time on a single UpCloud Cloud Server. You will generate a full set of secrets and verify the API keys against a running instance, put the gateway behind Caddy with automatic certificates, lock Studio behind authentication and a firewall, wire up SMTP so signup confirmation actually sends, tune Postgres against the container’s memory ceiling, and set per-service limits so a runaway container cannot take the database down with it.

The reference stack is one Premium Cloud Server running Ubuntu 26.04 LTS with 4 cores and 8 GB RAM (plan identifier PREMIUM-4xCPU-8GB, 100 GB of MaxIOPS storage), the Supabase Docker stack at release tag self-hosted/v0.8.2, Caddy terminating TLS, and a domain with two hostnames pointing at the box.

You need:

  • A domain you can add DNS records for
  • SMTP credentials from a transactional email provider, with a verified sender address
  • Basic SSH usage, including generating an SSH key pair and connecting to a remote host
  • A private Git repository to hold your copy of the stack configuration

Once you have these in place, follow along!

Step 1: Server sizing and preparation

RAM is the binding constraint. Supabase documents a 4 GB minimum with 8 GB recommended. Take the recommendation, because lower might struggle to absorb shared buffers, connection memory, image transformation spikes, and Realtime’s per-subscription cost. PREMIUM-4xCPU-8GB from the Premium plan family gives you 8 GB, 4 cores, and 100 GB of MaxIOPS storage.

If you haven’t already, deploy a Cloud Server using the recommended configuration. Once the server is provisioned, add swap on anything at or below 8 GB. Postgres and the BEAM services both allocate in bursts, and the OOM killer taking a container mid-query is worse than a few seconds of paging:

fallocate -l 4G /swapfile && chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
echo 'vm.swappiness=10' >> /etc/sysctl.conf && sysctl -p

Swappiness of 10 keeps the kernel from paging out shared buffers under normal pressure while leaving swap as an emergency reserve.

The firewall accepts SSH and the two web ports. Everything else reaches the outside world through the reverse proxy or an SSH tunnel:

ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp && ufw allow 80/tcp && ufw allow 443/tcp
ufw enable

Port 8000 stays closed for the whole guide. Ports 5432 and 6543 also stay closed, which is what keeps the connection pooler off the public internet given that the compose file publishes both to the host.

Create a non-root user and add it to the docker group:

adduser deploy
groupadd -f docker
usermod -aG sudo,docker deploy
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i 's/^#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl restart ssh

Membership in the docker group is equivalent to root on this machine, since any member can start a container that bind-mounts / and writes to it as the host’s root user. Docker’s documentation treats the group as a privileged boundary, so keep the membership list to people who already have sudo.

Install Docker from Docker’s own repository, because Ubuntu’s archive lags and the deploy.resources syntax in step 8 needs Compose v2:

curl -fsSL https://get.docker.com | sh
docker compose version

Put the project under /opt/supabase and run everything from here as deploy. The upstream layout keeps persistent data inside the project directory, with Postgres writing to volumes/db/data and Storage writing to volumes/storage as bind mounts, so configuration and data share a tree. Treat those two paths as the data set when you back one up and exclude the other.

Step 2: Clone the stack and pin your version

Supabase ships a bootstrap script that sparse-clones the docker directory out of the monorepo into a project directory of its own. Run it against an explicit release tag:

mkdir /opt/supabase && cd /opt/supabase
curl -fsSL https://supabase.link/setup.sh -o setup.sh
sh setup.sh --project-dir stack --skip-deps --ref self-hosted/v0.8.2

The --ref flag is the important one. Without it the script resolves whatever self-hosted/v* tag is latest at the moment you run it, so two people following the same instructions a month apart get different image sets. The script writes .supabase-version recording the ref you started from, and the update procedure three-way merges upstream changes against it so local edits survive. Losing that file leaves the next update with no base to merge from.

Commit your copy to a private repository before changing anything:

cd /opt/supabase/stack
git init && git add -A
git commit -m "Supabase self-hosted at self-hosted/v0.8.2"
git remote add origin [email protected]:yourorg/supabase-stack.git
git push -u origin main

The upstream .gitignore excludes .env, the data directories, backups/, .supabase-version, and docker-compose.override.yml. Two of those work against you. Remove the .supabase-version and docker-compose.override.yml lines now, before either file exists. The override file doesn’t show up until step 5, but once it does it holds every local change you make from there onward, and it’s the one file the updater never touches. Leave .env excluded.

Pinning the version also pins exactly what runs. The compose file brings up eleven containers, and knowing what each one does is what lets you judge which ones your deployment actually needs, which is the next decision:

ServiceImageResponsibility
dbsupabase/postgres:17.6.1.136Postgres with the Supabase extensions, roles, and schemas
api-gwenvoyproxy/envoy:v1.39.1API gateway, routes public paths and validates API keys
authsupabase/gotrue:v2.196.0Signup, login, JWT issuance, password recovery, OAuth
restpostgrest/postgrest:v14.17REST API generated from the database schema
realtimesupabase/realtime:v2.134.10WebSocket subscriptions, broadcast, and presence
storagesupabase/storage-api:v1.74.0File upload and download with row level security on objects
imgproxydarthsim/imgproxy:v3.31.4Image transformation for stored objects
metasupabase/postgres-meta:v0.99.0Schema introspection API that Studio reads
studiosupabase/studio:2026.09.07-sha-7996410The dashboard
functionssupabase/edge-runtime:v1.76.2Deno runtime for edge functions
supavisorsupabase/supavisor:2.9.12Connection pooler, publishes host ports 5432 and 6543

Envoy replaced Kong as the default gateway during 2026, and Kong remains available with sh run.sh config add kong for deployments carrying custom kong.yml routing.

In this list, four services are optional.

  • You can drop functions if you have no Deno edge functions, which is common for teams running their own application server.
  • You can drop storage and imgproxy together if the application never accepts uploads, since Storage is imgproxy’s only consumer.
  • You can drop realtime if nothing subscribes to database changes, and confirm that first, because Realtime failures are silent from the client’s side.
  • Also, you can treat supavisor as mandatory: the db service publishes no host ports at all, so the pooler is the only route to Postgres from outside the Docker network.

Make sure to record what you deployed, so that when something breaks in four months the question “what changed” has an answer you can diff:

docker compose config –images | sort > deployed-images.txt
git add deployed-images.txt && git commit -m “Record deployed image tags”

Step 3: Generate secrets and API keys

Every secret in the shipped .env.example is published in a public repository: POSTGRES_PASSWORD, JWT_SECRET, ANON_KEY and SERVICE_ROLE_KEY (both signed with that published secret), DASHBOARD_PASSWORD, SECRET_KEY_BASE, VAULT_ENC_KEY, REALTIME_DB_ENC_KEY, PG_META_CRYPTO_KEY, the two S3_PROTOCOL_* values, and both Logflare tokens. A deployment that starts with any of them intact is readable and writable by anyone who has opened the repository.

You can use two scripts in utils/ to replace all of them:

cd /opt/supabase/stack
cp .env.example .env
sh utils/generate-keys.sh --update-env
sh utils/add-new-auth-keys.sh --update-env

The first generates fifteen values with openssl rand and signs fresh ANON_KEY and SERVICE_ROLE_KEY tokens against the new JWT_SECRET. The second reads that secret back, generates an EC P-256 key pair, and writes JWT_KEYS and JWT_JWKS alongside opaque SUPABASE_PUBLISHABLE_KEY and SUPABASE_SECRET_KEY values. Asymmetric signing means the services that verify tokens hold only the public half, so a compromised PostgREST or Storage container cannot mint new ones.

Verify the keys against a running instance, since the generation step only tells you the script completed. The gateway’s own RBAC rules restrict the bare /rest/v1/ path to service_role and ignore anon there entirely, so check the schema with service_role and check anon against a sub-path instead:

sh run.sh start

# source .env fails here: STUDIO_DEFAULT_ORGANIZATION and STUDIO_DEFAULT_PROJECT
# are unquoted multi-word values, and the shell tries to run the second word as a command

export $(grep -E '^(ANON_KEY|SERVICE_ROLE_KEY)=' .env)

# PostgREST verifies the signature, so a JSON schema description means it validates.
# Only service_role is allowed on the bare /rest/v1/ route at the gateway level.

curl -s http://localhost:8000/rest/v1/ -H "apikey: ${SERVICE_ROLE_KEY}" | head -c 120

# A 401 means the anon key’s signature doesn’t match JWT_SECRET. A 403 means the
# gateway rejected the key itself. Anything else, even a 404 for the missing function,
# means both checks passed.

curl -s -o /dev/null -w '%{http_code}\n' \
http://localhost:8000/rest/v1/rpc/ -H "apikey: ${ANON_KEY}"

Decoding the token payload locally shows you the claims and stops there, because the signature check happens inside PostgREST. Run the request.

The service_role key bypasses row level security completely, which makes it equivalent to unrestricted database access over HTTP. It belongs in server-side environment variables on machines you control: a backend API, a cron worker, a migration runner. Keep it out of browser bundles, mobile binaries, client components, and any repository more people can read than can already reach the database. The anon key is the one that ships to clients, and it is only safe because RLS constrains it, which makes writing policies part of the setup work.

Dashboard credentials deserve the same treatment as the database password, because Studio connects as the postgres role and exposes a SQL editor. Anyone who reaches the dashboard and logs in has arbitrary query access against your data.

Rotating JWT_SECRET means re-running generate-keys.sh and recreating everything that issues or verifies tokens with sh run.sh recreate --except db imgproxy. Every access token issued under the old secret stops validating immediately. Clients holding a valid refresh token recover on their next refresh call, because refresh tokens are opaque rows in auth.refresh_tokens and survive the change, so the visible breakage lasts up to JWT_EXPIRY seconds.

Rotating POSTGRES_PASSWORD is different, because that value was written into the database at initialization and editing .env afterwards changes only what the clients present. Change the roles first:

ALTER ROLE postgres WITH PASSWORD 'new-password';
ALTER ROLE supabase_admin WITH PASSWORD 'new-password';
ALTER ROLE supabase_auth_admin WITH PASSWORD 'new-password';
ALTER ROLE supabase_storage_admin WITH PASSWORD 'new-password';
ALTER ROLE authenticator WITH PASSWORD 'new-password';

Then update .env and recreate. Skipping these statements produces authentication failures across every service at once, which step 9 covers.

Step 4: Reverse proxy and certificates

The compose file publishes api-gw on host port 8000 over plain HTTP. Supabase ships a Caddy override that removes that binding and puts Caddy in front on 80 and 443, requesting certificates from Let’s Encrypt automatically:

sh run.sh config add caddy
sh run.sh config

The resolved list should read docker-compose.yml:docker-compose.caddy.yml. The override sets ports: !reset [] on api-gw, so port 8000 disappears from the host entirely.

Point two A records at the server before starting Caddy, since certificate issuance fails against a hostname that does not resolve: api.example.com for the API and studio.example.com for the dashboard. SITE_URL below needs a third domain, but one that resolves to your frontend application rather than this server, so it carries no A record here. Then set the URLs in .env:

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

SUPABASE_PUBLIC_URL is what Studio and Storage use to build absolute URLs, and API_EXTERNAL_URL is what GoTrue writes into confirmation emails.

The shipped Caddyfile at volumes/proxy/caddy/Caddyfile routes by path, sending a fixed list of API prefixes to the gateway and everything else to Studio behind HTTP basic authentication:

{$PROXY_DOMAIN} {
@supabase_api path /auth/v1/* /rest/v1/* /graphql/v1 /realtime/v1/* /storage/v1/* /functions/v1/* /mcp /sso/* /.well-known/oauth-authorization-server
handle @supabase\_api {  
    reverse\_proxy api-gw:8000  
}

handle {  
    basic\_auth {  
        {\$PROXY\_AUTH\_USERNAME} {\$PROXY\_AUTH\_PASSWORD}  
    }  
    reverse\_proxy studio:3000  
}

header \-server  
}

That matcher list is the complete set of paths a Supabase client library needs. Three things stay off the public internet: Postgres on 5432, the transaction pooler on 6543, and Logflare on 4000, which the logs override leaves commented out.

WebSocket upgrades are the step most likely to look fine while Realtime silently fails. Caddy’s reverse_proxy handles the upgrade handshake without configuration. An Nginx deployment needs proxy_set_header Upgrade and Connection "upgrade" set explicitly on the /realtime/v1/ location, plus a proxy_read_timeout well above the 60 second default, since that default closes idle subscriptions and clients reconnect in a loop that reads as network flapping. Leaving the headers out produces an API that answers every REST call correctly while every .subscribe() hangs and times out with no server-side error to find.

Request body limits follow the same pattern. Caddy imposes no default limit, so uploads are bounded by Storage’s own FILE_SIZE_LIMIT of 52428800 bytes, or 50 MB. Nginx defaults client_max_body_size to 1 MB and returns a bare 413 before Storage sees the request, so set it to match.

Bring the proxy up and confirm the boundaries hold:

sh run.sh recreate
curl -sI https://api.example.com/rest/v1/ -H "apikey: ${ANON_KEY}" | head -1
curl -s https://api.example.com/auth/v1/health -H "apikey: ${ANON_KEY}"
curl -m 5 -sI http://api.example.com:8000/ ; echo "exit: $?"

The last command should time out or refuse. An HTTP response means the override did not apply.

Step 5: Lock down Studio

Studio connects as postgres, ships a SQL editor, and exposes the user table, the storage browser, and every row in every table. Anyone who reaches it and authenticates has the same access as someone holding the service_role key, with a more convenient interface for using it.

Rank the three approaches by what they actually protect against. An SSH tunnel is strongest, because it removes the dashboard from the public internet entirely, leaving no login form to brute force and gating access behind the same key that gates the server. An IP allowlist at the proxy is the middle option, working well for teams with static addresses or a VPN with a known egress range and degrading badly when someone needs access from a hotel. HTTP basic authentication is the weakest and the one the stack ships with, putting a single shared password in front of the dashboard with no second factor and no record of who logged in.

Use the SSH tunnel. Publish Studio on loopback only. run.sh config add only accepts a file that already exists, and setting COMPOSE_FILE in .env turns off Compose’s automatic pickup of new override files, so write docker-compose.override.yml first and register it second:

cat > docker-compose.override.yml <<'EOF'
services:
studio:
ports:
- "127.0.0.1:3000:3000"
EOF
sh run.sh config add override
sh run.sh recreate studio

Overrides apply left to right, so the resolved list should end with docker-compose.override.yml. Every local change from here onward lands in that same file. Registering the override only updates COMPOSE_FILE in .env, it doesn’t touch the running container, so without that recreate Studio keeps running on whatever ports it already had and nothing is listening on 127.0.0.1:3000 yet.

Reach it with ssh -L 3000:127.0.0.1:3000 [email protected] and open http://localhost:3000, then remove the handle block from the Caddyfile so the dashboard has no public route at all.

When a team genuinely needs browser access from changing locations, fall back to basic authentication on its own hostname so the access rules can differ from the API:

api.example.com {
reverse_proxy api-gw:8000
header -server
}
studio.example.com {
@allowed remote_ip 203.0.113.10 198.51.100.0/24
handle @allowed {
basic_auth {
{$PROXY_AUTH_USERNAME} {$PROXY_AUTH_PASSWORD}
}
reverse_proxy studio:3000
}
respond 403
header -server
}

Confirm the dashboard is unreachable from outside your office network before moving on. A 403 from https://studio.example.com/ and connection failures against ports 3000 and 8000 on the server IP is the result you want.

Step 6: Configure SMTP and auth settings

The default SMTP_HOST is supabase-mail, a container the current compose file does not include. GoTrue starts cleanly, reports healthy, accepts signups, and fails every send against a hostname that does not resolve, with the failure appearing only in the auth container’s logs:

SMTP_HOST=smtp.yourprovider.com
SMTP_PORT=587
SMTP_USER=your-smtp-username
SMTP_PASS=your-smtp-password
SMTP_SENDER_NAME=Your Product
SMTP_ADMIN_EMAIL=[email protected]

Use 587 or 465. UpCloud blocks outbound port 25 by default on new accounts and documents those two as the open alternatives in its SMTP guidance, so a configuration pointing at 25 produces connection timeouts that look like a provider outage.

Two fields cause silent send failures. SMTP_ADMIN_EMAIL becomes the From address, and most transactional providers reject any message whose sender is not a verified identity on the account, returning a 550 that GoTrue logs and discards. SMTP_SENDER_NAME left empty produces a malformed From header that some providers accept and others reject. Make the admin address one you can receive mail at, because bounce notifications go there.

GoTrue builds a confirmation link as API_EXTERNAL_URL plus MAILER_URLPATHS_CONFIRMATION, with the destination passed as a redirect_to parameter that must match SITE_URL or appear in ADDITIONAL_REDIRECT_URLS. Leaving API_EXTERNAL_URL at its default sends every user a link beginning http://localhost:8000, which resolves to the recipient’s own machine. A redirect_to value outside the allowlist produces a link that verifies the token correctly and then drops the user on the default page with no session:

ADDITIONAL_REDIRECT_URLS=https://app.example.com/auth/callback,https://staging.example.com/auth/callback

Close open signup where the application does not need it. Internal tools and anything where accounts are provisioned by an administrator should set DISABLE_SIGNUP=true, which turns off the public endpoint while leaving invites working. Keep ENABLE_EMAIL_AUTOCONFIRM=false in any deployment that sends mail, since setting it true marks addresses confirmed without verification.

Default GoTrue emails are plain text with a bare link, which reads as phishing to most recipients and lands in spam more often than a styled message. Point the mailer at your own templates in the override file:

services:
auth:
environment:
GOTRUE_MAILER_SUBJECTS_CONFIRMATION: "Confirm your email"
GOTRUE_MAILER_TEMPLATES_CONFIRMATION: https://app.example.com/email/confirm.html
GOTRUE_MAILER_TEMPLATES_RECOVERY: https://app.example.com/email/recovery.html
GOTRUE_MAILER_TEMPLATES_INVITE: https://app.example.com/email/invite.html

GoTrue fetches those URLs at send time, so they must be reachable from inside the container and stay reachable. Confirm with docker exec supabase-auth wget -qO- <url>.

Test against a real inbox, since a clean container start and a healthy auth endpoint tell you GoTrue is running and delivery is a separate question:

curl -s -X POST https://api.example.com/auth/v1/signup \
-H "apikey: ${ANON_KEY}" -H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"a-real-password-here"}'
curl -s -X POST https://api.example.com/auth/v1/recover \
-H "apikey: ${ANON_KEY}" -H "Content-Type: application/json" \
-d '{"email":"[email protected]"}'

Open both emails, click both links, and confirm each lands on a page in your application with a session attached. When nothing arrives, sh run.sh logs auth carries the provider’s rejection verbatim, and it is almost always an unverified sender or a rotated credential.

Step 7: Tune Postgres for the box

The supabase/postgres image ships a configuration sized for a small container and has no idea how much memory you gave it. Tune against the limit you set in step 8, which is 3 GB for the database on an 8 GB host, leaving the rest for the other ten services and the page cache.

Sizing against the host total is the common mistake: shared_buffers of 2 GB looks reasonable on an 8 GB box until the container ceiling is 3 GB, at which point Postgres commits two thirds of its budget to buffers before serving a connection.

# /etc/postgresql-custom/conf.d/99-tuning.conf

# 25% of the container limit. The OS page cache covers the rest.
shared_buffers = 768MB
effective_cache_size = 2GB

# Allocated per sort or hash node, so one query can use several.
# 100 connections at 8MB is 800MB worst case, which fits the budget.
work_mem = 8MB
maintenance_work_mem = 256MB

# Internal Supabase services hold roughly 40 of these.
max_connections = 100

# MaxIOPS storage is NVMe-backed, so random reads cost close to sequential.
random_page_cost = 1.1
effective_io_concurrency = 200

checkpoint_completion_target = 0.9
max_wal_size = 4GB

Placement is what keeps this file alive across image updates. The image’s postgresql.conf ends with include_dir = '/etc/postgresql-custom/conf.d', and the compose file mounts /etc/postgresql-custom from a named Docker volume called db-config. Anything written there survives container recreation and image tag changes, because the volume outlives both. Files written anywhere else in the image are discarded the moment you pull a new tag.

docker exec supabase-db mkdir -p /etc/postgresql-custom/conf.d
docker cp 99-tuning.conf supabase-db:/etc/postgresql-custom/conf.d/99-tuning.conf
sh run.sh restart db

Keep a copy in your Git repository, because the volume survives updates and does not survive reset.sh.

Confirm the settings took effect, since a syntax error in an included file makes Postgres fall back to defaults with only a log line to show for it:

SELECT name, setting, source, sourcefile
FROM pg_settings
WHERE name IN ('shared_buffers', 'work_mem', 'effective_cache_size',
'max_connections', 'maintenance_work_mem');

The sourcefile column should read /etc/postgresql-custom/conf.d/99-tuning.conf for every row. A source of default means the file was not read.

Supavisor publishes two ports that behave differently. Port 5432 forwards session-mode connections through to Postgres, holding one backend per client for the life of the connection. Port 6543 runs transaction mode, returning the backend at the end of each transaction so many clients share a small pool.

The threshold for moving to 6543 is arithmetic on worker count. Supabase’s internal services hold roughly 40 connections at idle across PostgREST, Storage, Auth, Realtime, Meta, and the pooler itself, leaving about 60 for application traffic. Four workers with a pool of 10 each is 40 connections and fits. Eight workers at 10 is 80 and does not. Transaction mode costs you prepared statements, LISTEN/NOTIFY, session-level SET, and advisory locks held across statements, so most ORMs need a flag set before they work against it.

Step 8: Resource limits and restart policy

None of the eleven services carry a memory limit by default, which means any one of them can consume the whole box. The limits go in the docker-compose.override.yml you registered in step 5:

services:
db:
deploy:
resources:
limits:
memory: 3G
cpus: "2.0"
realtime:
deploy:
resources:
limits:
memory: 1G
cpus: "1.0"

Starting values for the rest on an 8 GB host: 768M for studio and supavisor, 512M for storage, imgproxy, and functions, and 256M for meta, auth, rest, and api-gw. Those totals exceed 8 GB on purpose, because Compose resource limits cap what a container can take while reserving none of it up front. The work they do is bounding the blast radius, so a leaking Realtime container gets killed at 1 GB and restarts while Postgres keeps its 3 GB.

Editing the override file doesn’t touch any running container, so recreate the whole stack once every service has its limit written in:

sh run.sh recreate

The container that made this concrete on the reference build was analytics. Logflare with the Postgres backend grows its working set as log volume grows, and with the logs override enabled and no limit it climbed past 2.5 GB over about a day of moderate traffic, at which point the host went to swap and query latency went with it. Postgres absorbed the damage from a container that has nothing to do with serving queries.

Restart policy needs one adjustment. Every long-running service uses restart: unless-stopped, which is correct. Avoid always, because it restarts containers when the Docker daemon starts even when you stopped them deliberately, so a reboot silently undoes a service you took out of rotation. One-shot containers need no policy at all, and giving one to the minio-createbucket container in the S3 override puts it in a loop.

Docker’s JSON logging driver has no size limit by default, and a chatty container fills a disk over weeks with nothing in the monitoring until writes start failing. Cap it in /etc/docker/daemon.json, then restart the daemon and recreate the stack, since the setting applies to containers created afterwards:

{
"log-driver": "json-file",
"log-opts": { "max-size": "50m", "max-file": "3" }
}

Healthcheck dependencies form a chain worth understanding before you debug the wrong container. api-gw declares depends_on: studio: condition: service_healthy, so the gateway waits on the dashboard. With the logs override enabled, studio declares the same dependency on analytics. A Logflare container in a crash loop therefore keeps Studio from becoming healthy, which keeps the gateway from starting, which takes down REST, auth, storage, and realtime for reasons that have nothing to do with any of them. The symptom is a total API outage with every dependent service reporting healthy in docker compose ps. Give analytics a hard memory limit so it restarts before the host reaches swap, and if you do not read logs through Studio, leave the logs override off entirely.

Step 9: Bring it up and verify

sh run.sh start

That runs docker compose up -d --wait, which blocks until every healthcheck passes. Four containers legitimately take time on a cold start. db runs its initialization scripts on first boot and can take 60 seconds before pg_isready succeeds. supavisor has a 30 second start period and runs Ecto migrations against the _supabase database before it answers. realtime needs about 10 seconds plus its own tenant migration, and studio has a 20 second start period while Next.js warms up. Two to three minutes is normal, and anything past five means something is failing, so go read the logs.

Three failures accounted for most of the trouble on the reference build:

  • Authentication errors across several services at once, with supabase-auth, supabase-storage, and supabase-pooler all logging password authentication failed for user, mean POSTGRES_PASSWORD changed in .env after the data directory already existed. Fix with the ALTER ROLE statements from step 3, or delete volumes/db/data and start over if there is no data worth keeping.
  • supabase-pooler restarting in a loop with an error about the _supabase database means it started against a data directory created before volumes/db/_supabase.sql was mounted. sh run.sh recreate db re-runs the mounted migrations.
  • supabase-envoy never starting while everything else looks fine points at Studio, because the dependency runs in that direction. Check sh run.sh logs studio before touching the gateway.

Work through the checklist once the stack is healthy. For the row level security items, create a table with RLS enabled and one row in it:

CREATE TABLE notes (id serial PRIMARY KEY, body text);
ALTER TABLE notes ENABLE ROW LEVEL SECURITY;
INSERT INTO notes (body) VALUES ('rls test row');

# grep, not source .env: STUDIO_DEFAULT_ORGANIZATION and STUDIO_DEFAULT_PROJECT
# are unquoted multi-word values that break a plain source

export $(grep -E '^(ANON_KEY|SERVICE_ROLE_KEY)=' .env)

# 1. HTTPS API responds with a valid certificate

curl -sI https://api.example.com/rest/v1/ -H "apikey: ${ANON_KEY}" | head -1

# 2. Auth healthy through the proxy

curl -s https://api.example.com/auth/v1/health -H "apikey: ${ANON_KEY}"

# 3. anon key respects RLS: expect an empty array

curl -s "https://api.example.com/rest/v1/notes?select=*" \
-H "apikey: ${ANON_KEY}" -H "Authorization: Bearer ${ANON_KEY}"

# 4. service_role key bypasses RLS: expect the row

curl -s "https://api.example.com/rest/v1/notes?select=*" \
-H "apikey: ${SERVICE_ROLE_KEY}" -H "Authorization: Bearer ${SERVICE_ROLE_KEY}"

# 5. Auth email delivered: run the signup from step 6 and open the inbox

# 6. Storage upload and retrieval

curl -s -X POST https://api.example.com/storage/v1/bucket \
-H "Authorization: Bearer ${SERVICE_ROLE_KEY}" -H "Content-Type: application/json" \
-d '{"id":"testbucket","name":"testbucket","public":false}'
echo "upload test" > /tmp/test.txt
curl -s -X POST https://api.example.com/storage/v1/object/testbucket/test.txt \
-H "Authorization: Bearer ${SERVICE_ROLE_KEY}" --data-binary @/tmp/test.txt
curl -s https://api.example.com/storage/v1/object/testbucket/test.txt \
-H "Authorization: Bearer ${SERVICE_ROLE_KEY}"

An empty array from item 3 and the row from item 4 confirms both your policies and your key derivation. The same row from both means RLS is disabled on the table and every anon request can read everything. Item 6 should print upload test, and a 413 means the proxy body limit from step 4 needs raising.

Realtime is the last item and needs a real client, because a curl against the WebSocket endpoint only confirms the port is open:

// npm install @supabase/supabase-js && node verify-realtime.mjs
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://api.example.com', process.env.ANON_KEY)
supabase.channel('verify')
.on('postgres_changes',
{ event: 'INSERT', schema: 'public', table: 'notes' },
(payload) => { console.log('received:', payload.new); process.exit(0) })
.subscribe((status) => console.log('channel status:', status))
setTimeout(() => {
console.error('no event in 30s: check the WebSocket upgrade path')
process.exit(1)
}, 30000)

Run it, then insert a row into notes. A SUBSCRIBED status followed by the payload means the upgrade path, the publication, and the token all work. SUBSCRIBED with no payload means the table is missing from the publication, which you fix with ALTER PUBLICATION supabase_realtime ADD TABLE notes;. A status that never reaches SUBSCRIBED points at the proxy’s WebSocket handling.

Passing all seven items is the point at which the install is real. Up to here you have a stack that starts, and starting is a much lower bar than working.

Conclusion: What comes next

You now own a database server. That is the accurate description of what the last nine steps produced, and it carries obligations that arrive on their own schedule:

  • OS patching, including kernel and Docker updates, with a reboot cadence for the fixes that cannot be applied live
  • Disk and memory watched by something that alerts, because the failure modes in step 8 are gradual and invisible until they are total
  • Certificate renewals, which Caddy handles automatically and which fail silently when DNS changes or a firewall rule blocks the ACME challenge. Alert on expiry, since a successful renewal is the thing you never need to hear about
  • Postgres backups, which nothing in this stack does for you. Run pg_dump on a schedule to storage in a different account, and perform at least one restore before you need it
  • Upstream releases, which is the obligation people underestimate

That last one is monthly work. Supabase publishes image updates to the self-hosting compose file roughly every month, and those updates carry the security fixes for GoTrue, PostgREST, Storage, Postgres, and Envoy. The hosted platform applies them for you. Here, somebody runs sh update.sh --dry-run, reads the breaking-change gate, takes a snapshot, runs sh update.sh followed by sh run.sh pull && sh run.sh recreate, and re-runs the step 9 checklist afterwards. The update script backs up configuration to backups/pre-update-*.tgz and explicitly does not back up Postgres or Storage data, so the snapshot is on you.

Against the hosted product, the trade is specific enough to state plainly. Supabase Pro is $25/month including $10 of compute credit, covering a Micro instance with 8 GB of database storage and 250 GB of egress. A PREMIUM-4xCPU-8GB Cloud Server gives you four cores, 8 GB of RAM, and 100 GB of MaxIOPS storage, with zero-cost egress. On raw resources per euro the self-hosted box wins comfortably. What you gave up is branching, managed point-in-time recovery, the platform management API, advanced metrics, and a team at Supabase who notices when the database is unhealthy at three in the morning. What you gained is a machine you control and a database whose size is bounded by a disk you can resize.

Two situations make self-hosting clearly correct. The first is a data residency or regulatory requirement dictating which jurisdiction and which infrastructure your data sits on, where the hosted product’s region list either satisfies it or does not. The second is running at a scale where hosted compute pricing has stopped making sense, which is a real threshold given that Supabase compute runs from $10/month for Micro to $3,730/month for a 16XL instance. Everyone outside those two is choosing self-hosting for other reasons, usually cost at small scale, where the saving is real and smaller than the time it costs to maintain.

That is the point to end on. This install is a machine somebody has to look after, and the difference between a self-hosted Supabase stack that runs for two years and one that dies in four months is whether that somebody has a name, time allocated, and a calendar reminder for the monthly update. Decide who that is before the first user signs up.

If your application eventually outgrows a single VPS or requires higher availability, you can also deploy Supabase on Kubernetes using UpCloud’s Managed Kubernetes and Managed Object Storage.

Discussion

Leave a Reply

Your email address will not be published. Required fields are marked *

Start Deploying!

Start your free 30-day trial today and discover why thousands of businesses trust UpCloud

  • €500 free credits
  • Risk-free trial
  • Optimized performance
  • Scalable infrastructure
  • Top-tier security
  • Global availability

Sign up

You're viewing the EU site. Switch to the Global site
Back to top