Self-hosted Supabase: your backend on your own server

Self-hosted Supabase means the open-source building blocks of Supabase (Postgres, authentication, APIs, real-time, storage, functions) running on your own server, with Docker. It often follows on from an app generated by Lovable or Bolt whose backend you want to keep within reach. Based on the official Supabase documentation, this guide covers the services, the configuration, what you set up yourself, migrating from Supabase Cloud, and when this choice is the right one.

Simon Vasconcelos Lee By Published on 5 December 20269 minute read

All guides Deploying an application

In short

  1. The official installation uses Docker Compose: eleven services by default, including Postgres, authentication, the REST API, real-time, storage and the Studio dashboard, behind an API gateway.
  2. Plan for at least 4 GB of memory, 2 cores and 40 GB of SSD; Supabase recommends 8 GB, 4 cores and 80 GB.
  3. Before the first start, every secret in the example gets replaced: database password, API keys, signing key pair, Studio access.
  4. HTTPS, sending email, updates and backups of Postgres and files are yours to handle.
  5. From Supabase Cloud, the database migrates in three exports (roles, schema, data); accounts come along, while storage files and functions are transferred separately.

The building blocks of self-hosted Supabase

Supabase publishes a Docker Compose configuration in its repository. It brings together open-source software, each piece in its own container, around a single Postgres database:

ServiceIts role
PostgresThe database, with the roles and extensions the other services expect
AuthSign-ups, sign-ins and sessions, with JWT tokens
PostgRESTThe REST API generated from your tables
RealtimeBroadcasting database changes to subscribed clients
StorageThe file API, with permissions held in Postgres; files on the server’s disk, or in S3-compatible storage
imgproxyImage transformation
Edge RuntimeFunctions in JavaScript, TypeScript or WASM, on Deno
SupavisorConnection pooling for Postgres
postgres-metaThe API that lets Studio manage the database
StudioThe dashboard
API gatewayEnvoy by default, Kong as an option: the single entry point, on port 8000

Logs and analytics (Logflare, Vector) are an optional addition, with sh run.sh config add logs, and need extra resources.

A self-hosted instance corresponds to one project, configured mainly through environment variables. A few features are specific to the managed platform: branching, managed backups and point-in-time recovery (PITR), advanced metrics, ETL and the management API. Help with the self-hosted version comes through the community.

The recommended minimum configuration

ResourceMinimumRecommended
Memory4 GB8 GB or more
Processor2 cores4 cores or more
Disk40 GB of SSD80 GB of SSD or more

This minimum applies to the full set of services, for development as for small or medium production. If you leave out real-time, storage, imgproxy or functions, remove their sections from docker-compose.yml: the stack uses less. If your app runs on the same machine, add its memory, and keep headroom on the disk for the database and files, which live in volumes/db/data and volumes/storage.

On a Debian or Ubuntu server, the official script installs Docker, fetches the configuration, generates every secret and asks for your public addresses:

Quick install (Linux)
curl -fsSL https://supabase.link/setup.sh | sh
cd supabase-project && sh run.sh start

What you set up yourself

Secrets and keys

Supabase asks you to replace every example value in .env.example before the first start. The utils/generate-keys.sh script generates the passwords and secrets, then utils/add-new-auth-keys.sh adds the new API keys and the asymmetric key pair that signs tokens; the older ANON_KEY and SERVICE_ROLE_KEY keys are still accepted alongside them.

These secrets live in .env, and Supabase recommends a secrets manager in production. Keep this file out of Git and in your encrypted backups: it holds the keys that encrypt part of the data and sign sessions.

Access to Studio

Studio opens through the gateway, on port 8000, behind HTTP basic authentication (DASHBOARD_USERNAME, DASHBOARD_PASSWORD). It gives full control over the database: restrict it to your own addresses, with a firewall, a VPN or an SSH tunnel. The Supabase documentation also points to a guide that keeps Studio and Postgres off the public internet.

HTTPS and addresses

By default, everything goes over HTTP on port 8000. In production, and as soon as you offer sign-in with Google or GitHub, HTTPS is required: Supabase recommends a reverse proxy, Caddy or Nginx, in front of the gateway. Three variables say where the service answers: SUPABASE_PUBLIC_URL, API_EXTERNAL_URL (authentication callbacks) and SITE_URL (the default redirect to your app).

Sending email

Sign-up confirmation, forgotten password: authentication sends its emails through a production SMTP server that you provide (the SMTP_* variables in .env, then a restart of the services). A sending domain authenticated with SPF, DKIM and DMARC helps them land in the inbox.

Updates

Supabase publishes a stable release of the configuration about once a month, with images tested together. The update.sh script applies it through a three-way merge that keeps your secrets and settings; sh update.sh --dry-run first shows what would change. It backs up your configuration files: Postgres and storage data are backed up beforehand, separately.

Backups

Managed backups and point-in-time recovery belong to the platform: when self-hosting, they are yours to handle. A solid routine: every night, a database export (pg_dump, or supabase db dump), a copy of volumes/storage and .env, all encrypted and sent off the server; then, regularly, a test restore on another machine.

Migrating from Supabase Cloud

Supabase documents restoring a project from its platform to a self-hosted instance. You need the Supabase CLI (which relies on Docker), psql and the passwords for both databases. First enable, on the self-hosted instance, the non-standard extensions your project uses, then export and restore:

Export from Supabase Cloud, then restore
supabase db dump --db-url "$URL_CLOUD" -f roles.sql --role-only
supabase db dump --db-url "$URL_CLOUD" -f schema.sql
supabase db dump --db-url "$URL_CLOUD" -f data.sql --use-copy --data-only

psql --single-transaction --variable ON_ERROR_STOP=1 \
  --file roles.sql --file schema.sql \
  --command 'SET session_replication_role = replica' \
  --file data.sql --dbname "$URL_SELF_HOSTED"

supabase db dump runs pg_dump with Supabase-specific filtering (internal schemas excluded, reserved roles removed); a raw pg_dump would run into permission errors on restore. session_replication_role = replica suspends triggers during the import.

ItemHow it comes across
Schema, data, roles, RLS policies, functions, triggersIn the exports
User accounts (auth.users)In the exports; everyone signs in once more, as the platform’s tokens stop being valid
JWT keys and API keysNew ones, in .env, to carry over into the frontend
Sign-in with Google, Apple or GitHubGOTRUE_EXTERNAL_* variables, and redirect URLs updated at each provider
Storage filesTransferred separately, for example with the bucket-by-bucket copy script in the Supabase documentation
Functions (Edge Functions)Copied into volumes/functions
SMTP, domain and DNSConfigured on the new instance

The platform may run newer versions of authentication and storage: the data export then sometimes contains tables or columns that the instance does not know yet. Do a test restore first, and enable pg_graphql if your app uses it: a new instance on Postgres 17 leaves it disabled.

For an app on Lovable Cloud, the database is exported from Lovable as a .backup file, to be restored with pg_restore, and storage files are downloaded separately; Lovable lists self-hosted Supabase among its supported destinations. All that remains is to point VITE_SUPABASE_URL and the public key to your domain, then rebuild the frontend.

When self-hosting makes sense

Supabase presents it as suited to cases where you need full control over your data, where compliance requirements rule out managed services, or for an isolated environment. In practice, situations sort out like this:

Your situationWhat suits it
Your data must stay on a server you chooseSelf-hosted Supabase
Your app already runs on your server, and you want everything in one placeSelf-hosted Supabase, on the same machine or next to it
You rely on branching, point-in-time recovery or the management APISupabase Cloud
You want Supabase on your server without becoming a system administratorSelf-hosted Supabase on a managed VPS

Supabase itself lists what falls to whoever hosts it: preparing and maintaining the server, securing it, keeping the system and services up to date, maintaining Postgres, ensuring availability, backups, disaster recovery and monitoring.

To have this backend in-house without making it your job, a Managed VPS takes charge of the server: the host keeps the system up to date, monitors it day and night and steps in without waiting for your call, backs up every night, encrypted and off the machine, and restores for you. It also proactively monitors your app (errors, slowdowns, expensive queries, disk space) and recommends the fix, which you apply, yourself or through your AI assistant.

Your backend on your server, closely monitored

With a Simafri Managed VPS, our experts run the server behind your backend and proactively monitor your app: system and security updates, 24/7 monitoring with intervention before you even call, encrypted backups every night, kept off the machine, restores included. We spot errors, slowdowns and expensive queries and recommend the fix, which you apply, yourself or through your AI assistant; migration is free, at a time of your choosing.

Explore Managed VPS

Frequently asked questions

Is self-hosted Supabase free?

Its software is open source (MIT, Apache 2, PostgreSQL or equivalent licences), and the self-hosted instance sends no telemetry. You pay for the server that runs it, and for the time it takes to operate, whether you run it yourself or hand it over.

Will my users have to sign up again?

They keep their accounts: the auth.users table is part of the export, with the password hashes. The signing keys change, so tokens issued by the platform stop being valid: everyone signs in once more.

Which version of Postgres runs when self-hosting?

Postgres 17 by default, in the official Docker configuration, since its June 2026 release. An instance installed before then runs Postgres 15: Supabase documents its upgrade, with a script that keeps a copy of the original data.

Should Postgres be open to the internet?

Direct connections go through Supavisor, on port 5432 by default. Open that port to your own addresses only (your app, your tools), and let your frontend talk to the backend through the API, over HTTPS.

Contact us