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.
By Simon Vasconcelos Lee
Published on 5 December 20269-minute read
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:
| Service | Its role |
|---|---|
| Postgres | The database, with the roles and extensions the other services expect |
| Auth | Sign-ups, sign-ins and sessions, with JWT tokens |
| PostgREST | The REST API generated from your tables |
| Realtime | Broadcasting database changes to subscribed clients |
| Storage | The file API, with permissions held in Postgres; files on the server’s disk, or in S3-compatible storage |
| imgproxy | Image transformation |
| Edge Runtime | Functions in JavaScript, TypeScript or WASM, on Deno |
| Supavisor | Connection pooling for Postgres |
| postgres-meta | The API that lets Studio manage the database |
| Studio | The dashboard |
| API gateway | Envoy 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.
| Resource | Minimum | Recommended |
|---|---|---|
| Memory | 4 GB | 8 GB or more |
| Processor | 2 cores | 4 cores or more |
| Disk | 40 GB of SSD | 80 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:
curl -fsSL https://supabase.link/setup.sh | sh
cd supabase-project && sh run.sh start
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.
POSTGRES_PASSWORD: letters and digits only, for connection strings free of encoding issues.SUPABASE_PUBLISHABLE_KEY for the frontend; SUPABASE_SECRET_KEY for server code only.SECRET_KEY_BASE (at least 64 characters), VAULT_ENC_KEY (32), REALTIME_DB_ENC_KEY (16), PG_META_CRYPTO_KEY (at least 32): the internal encryption keys.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.
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.
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).
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.
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.
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.
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:
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.
| Item | How it comes across |
|---|---|
| Schema, data, roles, RLS policies, functions, triggers | In 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 keys | New ones, in .env, to carry over into the frontend |
| Sign-in with Google, Apple or GitHub | GOTRUE_EXTERNAL_* variables, and redirect URLs updated at each provider |
| Storage files | Transferred separately, for example with the bucket-by-bucket copy script in the Supabase documentation |
| Functions (Edge Functions) | Copied into volumes/functions |
| SMTP, domain and DNS | Configured 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.
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 situation | What suits it |
|---|---|
| Your data must stay on a server you choose | Self-hosted Supabase |
| Your app already runs on your server, and you want everything in one place | Self-hosted Supabase, on the same machine or next to it |
| You rely on branching, point-in-time recovery or the management API | Supabase Cloud |
| You want Supabase on your server without becoming a system administrator | Self-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.
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 complimentary, at a time of your choosing.
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.
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.
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.
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.
Simafri
Let's talk about your website
Tell us about your project in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.