Skip to content

Set Up Supabase on a Linux Server – Launch Your Open-Source Backend Platform

Learn how to host and configure Supabase for a reliable open-source Postgres platform with authentication and realtime features

27 November 202612 min read46 Views0 helpful

Introduction

Supabase is an open-source Postgres development platform that provides a complete Postgres database along with authentication, instant APIs, realtime features, and storage—a great open-source alternative to Firebase.

Want to host Supabase yourself? We’ll show you two ways: the easy way, as a One-Click App that makes Supabase available over HTTPS in just a few clicks, and a manual installation using Docker Compose via the console. Then you’ll learn how to use API keys securely, connect your app, and what’s different about self-hosting compared to Supabase Cloud.

When it makes sense to run Supabase on a VPS

Supabase is available as a hosted service (Supabase Cloud) and as a self-hosted option. A VPS of your own is especially useful if:

  • You want full control over your data: Your database, files, and user accounts are stored on your server, not with a third-party provider.
  • Regulations rule out hosted services: Supabase itself cites compliance requirements that prohibit managed services as a typical reason for self-hosting.
  • You need direct access to Postgres: You control the configuration, extensions, and database connection.
  • You’re looking for a backend for your own projects or a test and development environment that runs continuously alongside your other services.

Self-hosting is less suitable if you don’t want to manage servers, backups, and updates. According to Supabase, these responsibilities—as well as security, monitoring, and availability—are yours when self-hosting. In that case, help comes from the community, not Supabase Support.

Self-hosted or Supabase Cloud?

The self-hosted version is the same open-source software, but some features of the cloud platform are not available. The key differences, according to the Supabase documentation, are:

Self-hosted (VPS)Supabase Cloud
ProjectsOne project per installationMultiple organizations and projects
BackupsYou set them up yourselfManaged backups and point-in-time recovery
Branching, ETL, Management APINot availableAvailable
Operations and updatesYou take care of themSupabase takes care of them
SupportCommunitySupabase

If you only need one project with a database, authentication, storage, and realtime features, the self-hosted version has you covered.

The easy way: Supabase as a One-Click App

The quickest way to get your own Supabase instance is through your VPS’s One-Click Apps. All Supabase services start together, the app is available directly over HTTPS with a domain, and all keys and passwords are generated during installation. You don’t need to touch a repository or .env file.

Requirements

  • A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set Up One-Click Apps to learn how.
  • Supabase starts around 15 containers. The Supabase team recommends at least 4 GB RAM, 2 CPU cores, and 40 GB SSD storage for self-hosting; 8 GB RAM and 4 CPU cores are recommended.

Install

  1. Open your VPS in the ZapX dashboard and switch to the One-Click Apps tab.
  2. Search for Supabase in the App catalog and click Install app.
  3. Leave Use a custom subdomain or zap.cloud enabled and choose an address. You’ll use this address to access Supabase Studio and your project’s API.
  4. No field under App configuration is required, so you can leave everything at its default. However, if users should be able to register for your app by email, enter your mail server details here now. See Email delivery for sign-up below.
  5. Click Queue installation. The first time it starts, the VPS downloads the images for all services. The app will be online after a few minutes.

Sign in to Supabase Studio

Open the app’s Access link. It takes you to Supabase Studio, the web interface for your project. Your browser will ask for a username and password. You’ll find both in the app settings (gear icon) under App environment > Automatically generated values:

  • SERVICE_USER_ADMIN: username
  • SERVICE_PASSWORD_ADMIN: password

Use the eye icon to reveal a value, or the copy icon to copy it.

After signing in, you’ll see the overview for the “Default Project,” including the project URL. Use the Table Editor to create tables and the SQL Editor to run SQL directly on your Postgres database.

Connect your app to Supabase

You need the project URL and an API key for your app:

ValueWhere to find itPurpose
Project URLThe app’s Access link, for example https://your-name-1234.zap.cloudAddress for client libraries and the REST API at /rest/v1/
anon keyApp environment > Automatically generated values > SERVICE_SUPABASEANON_KEYFor browsers and apps; access is limited by your Row Level Security rules
service_role keyApp environment > Automatically generated values > SERVICE_SUPABASESERVICE_KEYFor servers and backends only; bypasses all Row Level Security rules

For example, the connection using the JavaScript library looks like this:

Code
import { createClient } from '@supabase/supabase-js'

const supabase = createClient('https://name-1234.zap.cloud', '<ANON_KEY>')
Warning: Keep the service_role key secret

Anyone with the service_role key has full access to your database. Never include it in a website or app that users download. Also enable Row Level Security for every table accessible through the API and create appropriate rules.

In Supabase Studio, the page for the new keys (publishable and secret) remains empty because the One-Click App uses the anon and service_role keys. This is expected.

Email delivery for sign-up

By default, anyone who registers by email must confirm their address using a link. Supabase only sends this email if a mail server is configured. To configure one, enter your mail provider’s details under App environment in the app settings (gear icon):

VariableValue
SMTP_HOSTSMTP server address
SMTP_PORTPort, usually 587
SMTP_USERMailbox username
SMTP_PASSMailbox password
SMTP_ADMIN_EMAILSender address, for example noreply@your-domain.com
SMTP_SENDER_NAMESender name

Then click Save. The app will restart. Two other values in the same place control sign-ups: Set ENABLE_EMAIL_AUTOCONFIRM to true to skip the confirmation email; this is only suitable for testing. Set DISABLE_SIGNUP to true to prevent anyone from registering themselves. You can then create users in Supabase Studio under Authentication.

Updates

To check whether an update is available for your installation, go to App update in the app settings (gear icon) and click Check for updates. If a new version is available, install it with Apply update. Your database and Storage files are stored in separate volumes and are preserved during the update.

Supabase Studio does not include its own backup feature in the self-hosted version. So before an update, export important tables—for example, as CSV files from the Table Editor.

Manual installation

The rest of this guide describes a manual installation of Supabase using Docker Compose via the console. This may be useful, for example, if you want to integrate Supabase into an existing server environment or control every step yourself. The instructions are based on the official Self-Hosting with Docker guide.

Requirements

  • A Linux server running Debian or Ubuntu that you can access via SSH.
  • A domain or subdomain with an A record pointing to your server’s IP address (e.g. supabase.example.com). You’ll use it to access Supabase Studio and the API over HTTPS.

In the default configuration, Supabase starts eleven containers. The Supabase team recommends the following:

HardwareMinimumRecommended
CPU2 vCPU cores4 vCPU cores or more
RAM4 GB8 GB or more
Disk space40 GB SSD80 GB SSD or more

Also allow for extra space for your Storage data and backups.

Preparation

First, bring your system up to date:

Code
sudo apt update && sudo apt upgrade -y

Then install Git to download the Supabase files from GitHub:

Code
sudo apt install git -y

Supabase runs in Docker containers. Install Docker with the Compose plugin as follows:

Code
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

For detailed instructions on installing and using Docker, see our Docker guide. Verify the installation with docker --version and docker compose version.

Prepare the firewall

Only SSH and the reverse proxy should be accessible from the internet, meaning ports 80 and 443. With ufw, this looks like this:

Code
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable

Do not open port 8000 (API gateway and Studio) or the database ports 5432 and 6543. For more information, see Managing the Firewall on Linux.

Warning: Docker bypasses ufw

Ports published by a container are accessible from the internet despite ufw, because Docker sets its own firewall rules. In the default Supabase configuration, this applies to port 8000 and the database pooler on ports 5432 and 6543. The “Configuration” and “Access via HTTPS through a reverse proxy” sections explain how to restrict these ports to the server itself.

Installation

Get the Supabase repository at the current self-hosting version, create a project directory, and copy the Docker files and example environment file into it:

Code
git clone --depth 1 --branch self-hosted/v0.8.5 https://github.com/supabase/supabase
mkdir supabase-project
cp -rf supabase/docker/. supabase-project
cd supabase-project && cp .env.example .env
docker compose pull

The version number in the command matches the version used for this guide. The official guide lists the latest version. Use the update script to install later updates (see “Update Supabase”).

Warning: Don’t start with the example values

The .env.example file contains publicly known passwords and keys. Don’t start Supabase until you’ve replaced them as described below. The database password is set on the first start.

Now generate all passwords and keys. The first script sets, among other things, POSTGRES_PASSWORD, JWT_SECRET, ANON_KEY, SERVICE_ROLE_KEY, and DASHBOARD_PASSWORD. The second adds the new API keys SUPABASE_PUBLISHABLE_KEY and SUPABASE_SECRET_KEY:

Code
sh utils/generate-keys.sh --update-env
sh utils/add-new-auth-keys.sh --update-env

Both scripts write directly to .env. The second requires Node.js or uses Docker if Node.js is not installed.

Configuration

Open .env with nano .env and update the addresses to match your domain:

VariableValuePurpose
SUPABASE_PUBLIC_URLhttps://supabase.example.comAddress for Studio and the API
API_EXTERNAL_URLhttps://supabase.example.com/auth/v1Links in emails, OAuth redirects
SITE_URLhttps://app.example.comAddress of your own app, where users return after signing in
DASHBOARD_USERNAMEYour own usernameSign-in to Supabase Studio

Also enter your mail server under SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS, SMTP_ADMIN_EMAIL, and SMTP_SENDER_NAME. The default supabase-mail is only a placeholder; Supabase won’t send confirmation emails without a real mail server.

By default, the database pooler publishes ports 5432 and 6543 on all network interfaces. To make Postgres accessible only from the server itself, create a custom override file. Create it with nano docker-compose.local.yml:

Code
services:
  supavisor:
    ports: !override
      - 127.0.0.1:${POSTGRES_PORT}:5432
      - 127.0.0.1:${POOLER_PROXY_PORT_TRANSACTION}:6543

Then add the file to the configuration:

Code
sh run.sh config add local

The run.sh script is in the project directory and adds the file to COMPOSE_FILE in .env. Run sh run.sh config to see which files are active.

Access via HTTPS through a reverse proxy

Supabase includes ready-to-use extensions for a reverse proxy. Caddy is the easiest option: it obtains the Let's Encrypt certificate itself, forwards WebSockets for realtime features, and protects Studio with your dashboard username and password. Add this line to .env:

Code
PROXY_DOMAIN=supabase.example.com

Then enable the Caddy extension and start Supabase:

Code
sh run.sh config add caddy
sh run.sh start

With Caddy, port 8000 no longer needs to be published, and Supabase is only accessible externally through ports 80 and 443. The first start takes a few minutes. Check the status of all containers with sh run.sh status, and view the logs with sh run.sh logs.

Info: nginx instead of Caddy

For nginx, use the corresponding extension with sh run.sh config add nginx, and also set CERTBOT_EMAIL in .env. If you already use your own proxy, forward it to port 8000, allow WebSockets for /realtime/v1/, and set the X-Forwarded headers. For the basics, see Set Up a Reverse Proxy with nginx and Create an SSL Certificate (Let's Encrypt).

First visit

Open https://supabase.example.com. Your browser will ask for the username and password for Supabase Studio. To view the values from your .env, run:

Code
sh run.sh secrets

After signing in, you’ll see the “Default Project.” Your app can access the API at the same address, for example, https://supabase.example.com/rest/v1/. The official guide explains multiple dashboard users, CORS, and other options.

Back up your data

Your installation’s data is stored in the following locations in the project directory:

  • volumes/db/data: the Postgres database, including tables, user accounts, and settings.
  • volumes/storage: files you upload to Storage.
  • volumes/functions: your Edge Functions.
  • .env: all passwords and keys. Without it, your backed-up data and API keys won’t match.

The key for encrypted database values is also stored in the Docker volume supabase_db-config. Create a full backup while the containers are stopped:

Code
cd ~/supabase-project
sh run.sh stop
tar -czf ~/supabase-backup-$(date +%F).tar.gz volumes .env
docker run --rm -v supabase_db-config:/data -v ~:/backup alpine tar -czf /backup/supabase-db-config-$(date +%F).tar.gz -C /data .
sh run.sh start

To export the database while it’s running, use pg_dump. The command writes the entire database to a file in compressed format:

Code
docker compose exec -T db pg_dump -h localhost -U postgres -d postgres -Fc > ~/supabase-$(date +%F).dump

Store backups off the server and protect them, as they contain credentials.

Update Supabase

Back up the database before every update. The included script then merges your configuration with the new version:

Code
cd ~/supabase-project
sh update.sh --dry-run
sh update.sh
sh run.sh pull && sh run.sh recreate

--dry-run shows what will change beforehand. For information about conflicts and version changes, see the Update Guide. Don’t manually mix image versions, or Supabase can’t guarantee compatibility.

API keys, connecting your app, and sign-in

Whether you use the One-Click App or a manual installation, the steps are the same from here on.

Use anon and service_role keys correctly

Supabase provides two types of keys for your app:

  • anon key (or publishable key): for browser and mobile apps. Anyone who knows it can only access what your Row Level Security rules allow.
  • service_role key (or secret key): for your server or backend only. It bypasses all rules and has full access to the database.

So enable Row Level Security for every table accessible through the API and create rules. Here’s an example for the SQL Editor, where each signed-in user can only see their own entries:

Code
alter table todos enable row level security;

create policy "read_own_todos"
on todos for select
to authenticated
using ( (select auth.uid()) = user_id );

Without a rule, a table with Row Level Security enabled returns no data through the anon key. This is safer than leaving a table open.

Connect your app

Your app needs the project URL and the anon key. For the One-Click App, the project URL is the Access link; for a manual installation, it’s the value of SUPABASE_PUBLIC_URL. The example above under “Connect your app to Supabase” shows how to connect using the JavaScript library. Official libraries are also available for Flutter, Swift, Kotlin, and Python, among others. Access the REST API at /rest/v1/ and sign-in at /auth/v1/.

Sign-in, emails, and redirects

For confirmation and password links to work, Supabase needs a mail server and your app’s correct address:

  • Mail server: the SMTP_* values—under App environment for the One-Click App, or in .env for a manual installation.
  • SITE_URL: your app’s address. Links in emails and sign-ins redirect users back here.
  • ADDITIONAL_REDIRECT_URLS: other permitted addresses, such as a development environment, separated by commas.
  • DISABLE_SIGNUP: when set to true, users can no longer register themselves. You can create users under Authentication in Studio instead.

After making a change, restart the app: click Save for the One-Click App, or run sh run.sh recreate for a manual installation.

Limitations compared to Supabase Cloud

  • One project per installation: Studio can’t manage additional projects or organizations. You need a second installation for a second project.
  • No managed backups: Point-in-time recovery, branching, ETL, and the Management API are only available in the cloud. You’ll need to set up backups yourself.
  • Logs and AI assistant: Logs & Analytics are disabled by default for manual installations. The AI assistant in Studio requires your own OPENAI_API_KEY.
  • Support: For issues with Supabase itself, get help from the community on GitHub and Discord, not Supabase Support.

Conclusion and further resources

You’ve installed Supabase on your server, made it accessible over HTTPS, protected the database from external access, and learned how to connect your app securely, create backups, and install updates.

Prefer not to deal with Docker yourself? Choose the easy One-Click App option described above under “The easy way: Supabase as a One-Click App.” Set up your domain, HTTPS, keys, and updates in just a few clicks.

Still have questions that aren’t answered here? Our support team is available every day to help—just get in touch! 🙂

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the quickest option: all Supabase services start together, Studio and the API are available over HTTPS at your subdomain, and passwords and API keys are generated during installation. You can install updates with a click. A manual Docker Compose installation makes sense if you want to integrate Supabase into an existing server environment, control the version, proxy, and configuration yourself, or work directly with the files and ports.
The Supabase team recommends at least 4 GB RAM, 2 CPU cores, and 40 GB SSD storage for self-hosting. They recommend 8 GB RAM or more, 4 CPU cores, and 80 GB SSD. Your actual storage needs depend on the size of your database and the files in Storage.
With self-hosting, the same open-source software runs on your server, giving you full control over your data and configuration. However, you’re responsible for backups, updates, and security, and support comes from the community. Each installation includes exactly one project. Managed backups with point-in-time recovery, branching, ETL, and the Management API are only available in Supabase Cloud.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.