Supabase gives you a Postgres database, sign-up and login, file storage, realtime updates and auto-generated APIs in one package. Many people call it the open-source alternative to Firebase. The hosted version is easy to start with, but you can also run the whole thing on your own VPS with Docker. Your data stays on your server, and the cost stays fixed as you grow.
This guide follows Supabase's official Docker setup (checked 1 December 2026) and adds what the official guide leaves to you on a real server: sizing, Nginx with free SSL, keeping the database ports private, backups and updates. It works on Ubuntu, Debian and AlmaLinux, with a short note for aaPanel users.
Short version: install Docker, get Supabase's Docker files, generate new secrets before the first start, bind ports 8000, 5432 and 6543 to 127.0.0.1, put Nginx with Let's Encrypt in front, and back up the database every night.
Why self-host Supabase?
- Your data, your server. Useful when clients want data kept on a server you control, or in India.
- Predictable cost. One VPS price, with no per-user or bandwidth surprises as your app grows.
- No project pausing or plan limits beyond what your server can handle.
The trade-off: you look after updates, backups and security yourself. If you'd rather not, the hosted Supabase platform is the easier choice. If you're happy on a Linux server, read on.
What size VPS do you need?
The default stack starts around 11 containers: Studio (the dashboard), the API gateway, Auth, the REST API, Realtime, Storage, image processing, postgres-meta, Edge Functions, Postgres and the Supavisor connection pooler. Supabase lists 4 GB RAM, 2 CPU cores and 40 GB disk as the minimum, and 8 GB+, 4 cores+ and 80 GB+ as recommended.
| Use | Plan | Why |
|---|---|---|
| Testing, a side project, a small internal app | LVPS-1: 4 vCPU, 8 GB RAM, 100 GB NVMe | Meets Supabase's recommended size, with room for one small app |
| A live app with real users | LVPS-2: 6 vCPU, 12 GB RAM, 200 GB NVMe | Headroom for Postgres cache, file uploads, your own app and the optional logs stack |
| Bigger databases or heavy file storage | LVPS-3 or a Storage VPS | More RAM for Postgres, or more disk for Storage |
Our Linux VPS plans run in Mumbai for users in India, or in Europe and the USA for a global audience, all on NVMe with the same price at renewal. Pick the location closest to your app's users. Not sure about sizing in general? See how much RAM and CPU your VPS needs.
Step 1: Install Docker
You need Docker Engine with the Compose plugin, plus git, openssl and jq. We cover the Docker install in our n8n on a VPS guide (step 1), so we won't repeat it here. Then add the other tools:
# Ubuntu / Debian
sudo apt install -y git openssl jq
# AlmaLinux / Rocky
sudo dnf install -y git openssl jq
Check Docker works with docker compose version.
Step 2: Get Supabase's Docker files
Supabase publishes tested snapshots of its Docker setup about once a month. Clone the current release tag (check the official guide for the newest one) and copy the files into your own project folder:
cd /opt
sudo git clone --depth 1 --branch self-hosted/v0.8.6 https://github.com/supabase/supabase
sudo mkdir supabase-project
sudo cp -rf supabase/docker/. supabase-project
cd supabase-project
sudo cp .env.example .env
printf 'ref=self-hosted/v0.8.6\n' | sudo tee .supabase-version
sudo docker compose pull
The .supabase-version file lets Supabase's update script upgrade this install safely later. Supabase also offers a one-line Linux installer that does all of this and generates the secrets. It's fine to use, but read the script first. The manual steps here show you exactly what changes on your server.
Step 3: Change every default password and key
The .env.example file contains example secrets that everyone can see. Supabase's guide says never to start with them. Generate your own before the first start:
sudo sh utils/generate-keys.sh
sudo sh utils/add-new-auth-keys.sh
The first script creates a strong database password and the other secrets. The second creates the publishable and secret API keys and the key pair used to sign logins (JWT). Then open .env and check these yourself:
DASHBOARD_USERNAMEandDASHBOARD_PASSWORD: the login for Studio. Use a long password with at least one letter.POSTGRES_PASSWORD: generated for you. Letters and numbers only avoid problems in connection strings.SUPABASE_PUBLISHABLE_KEYgoes in your frontend.SUPABASE_SECRET_KEYis for your server code only: never put it in a browser or mobile app.
Keep a copy of .env somewhere safe, off the server. Without it, you can't restore the same setup.
Step 4: Keep the ports off the public internet
This is the step most guides miss. By default the stack publishes three ports on every network interface: 8000 (the API gateway and Studio), 5432 and 6543 (the Postgres pooler). Docker adds its own firewall rules for published ports, and they skip ufw and firewalld. So even with a firewall that "blocks" 5432, your database pooler can still be reachable from the internet.
The fix is to bind these ports to 127.0.0.1, so only programs on the server itself (like Nginx) can reach them. In docker-compose.yml, find the ports: lines and add 127.0.0.1: in front.
Under api-gw:
ports:
- 127.0.0.1:${API_GW_HTTP_PORT:-${KONG_HTTP_PORT:-8000}}:8000/tcp
Under supavisor:
ports:
- 127.0.0.1:${POSTGRES_PORT}:5432
- 127.0.0.1:${POOLER_PROXY_PORT_TRANSACTION}:6543
Supabase's update script keeps local edits like these when you upgrade, but check the lines again after each update. In your firewall, open only 22 (SSH), 80 and 443. Need to reach the database from your own computer? Use an SSH tunnel instead of opening the port: ssh -L 5432:127.0.0.1:5432 user@your-server.
Step 5: Set your URLs and start Supabase
Pick a subdomain for Supabase, for example supabase.yourdomain.com, and point it to your server's IP with an A record (our guide to pointing a domain to a server shows how). Then set the URLs in .env:
SUPABASE_PUBLIC_URL=https://supabase.yourdomain.com
API_EXTERNAL_URL=https://supabase.yourdomain.com/auth/v1
SITE_URL=https://yourapp.com
SITE_URL is your own app's address, where users land after they sign in. Now start the stack:
sudo sh run.sh start
sudo docker compose ps
After a minute, every service should show Up (healthy). If one doesn't, sudo sh run.sh logs <service> shows why.
Step 6: Nginx with free SSL in front
Studio and all the APIs come through the same gateway on port 8000, so one Nginx site covers everything. Install Nginx and Certbot:
# Ubuntu / Debian
sudo apt install -y nginx certbot python3-certbot-nginx
# AlmaLinux / Rocky (Certbot comes from EPEL)
sudo dnf install -y epel-release
sudo dnf install -y nginx certbot python3-certbot-nginx
sudo systemctl enable --now nginx
sudo setsebool -P httpd_can_network_connect 1
The last line is for AlmaLinux and Rocky only: SELinux blocks Nginx from connecting to port 8000 until you allow it, and you'd see "502 Bad Gateway". Then create /etc/nginx/conf.d/supabase.conf:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name supabase.yourdomain.com;
client_max_body_size 50m;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
}
}
The Upgrade and Connection lines are needed for Realtime (WebSockets). client_max_body_size sets the largest file upload, so raise it if your app uploads bigger files. Test, reload and add the certificate:
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d supabase.yourdomain.com
Certbot sets up HTTPS and renews the certificate automatically. Check it works: curl -I https://supabase.yourdomain.com/auth/v1/ should answer with 401, which means the connection reached Auth. Open https://supabase.yourdomain.com in a browser and log in to Studio with your dashboard username and password.
Supabase also ships ready-made Caddy and Nginx containers (sh run.sh config add caddy). They're a good choice on a server that runs nothing else. If the server already has a web server on ports 80 and 443, use that one as shown above.
Using aaPanel? Use its Nginx instead
On a server with aaPanel (common on AlmaLinux), aaPanel's Nginx already owns ports 80 and 443. Don't install a second Nginx or start Supabase's Caddy, as they'd fight over the same ports. Instead:
- In aaPanel, add a site for
supabase.yourdomain.com. - In the site's settings, add a reverse proxy to
http://127.0.0.1:8000. - Turn on SSL for the site with Let's Encrypt from aaPanel.
- If Realtime doesn't connect, add the
UpgradeandConnectionheaders from the config above to the site's proxy settings.
Step 4 still applies: bind Supabase's ports to 127.0.0.1, as aaPanel's firewall page doesn't control Docker's ports either.
Step 7: Back up every night
A VPS snapshot is a good safety net before changes, but you also want a daily database copy. Postgres is only reachable through the pooler by default, so run pg_dump inside the database container:
sudo mkdir -p /backups
cd /opt/supabase-project
sudo docker compose exec -T db pg_dump -U postgres -Fc postgres > /backups/supabase-$(date +%F).dump
Make it automatic with sudo crontab -e. This keeps seven days of copies:
0 2 * * * cd /opt/supabase-project && docker compose exec -T db pg_dump -U postgres -Fc postgres > /backups/supabase-$(date +\%F).dump && find /backups -name 'supabase-*.dump' -mtime +7 -delete
Also back up the uploaded files in volumes/storage and your .env. Copy all of it off the server too, for example to a Storage VPS, because a backup on the same server doesn't help if the server is lost. Try a restore on a spare VPS once, so you know it works.
Step 8: Update safely
Supabase's update.sh pulls the newest release and merges it with your files, keeping your .env and your edits. It does not back up your database or files, so take a snapshot and a fresh pg_dump first. Then:
cd /opt/supabase-project
sudo sh update.sh --dry-run
sudo sh update.sh
sudo sh run.sh pull
sudo sh run.sh recreate
Read the output, especially any conflicts or breaking-change notices, before you continue. Afterwards, check that the 127.0.0.1: port bindings from step 4 are still in place.
Common problems
| Problem | Likely cause | Fix |
|---|---|---|
| 502 Bad Gateway from Nginx | Supabase not running, or SELinux blocking Nginx on AlmaLinux | sudo docker compose ps, and setsebool -P httpd_can_network_connect 1 |
| Realtime subscriptions don't connect | WebSocket headers missing in the proxy | Add the Upgrade / Connection lines from step 6 |
| Login redirects go to the wrong place | API_EXTERNAL_URL or SITE_URL still on http or the old address | Fix the URLs in .env, then sudo sh run.sh recreate |
| A service stays "created" or unhealthy | A wrong value in .env, or not enough RAM | sudo sh run.sh logs <service> and check free memory with free -h |
| Port 5432 open to the world in a port scan | Docker publishes ports past the firewall | Bind the ports to 127.0.0.1 (step 4) |
Want a VPS for Supabase without guessing? Our Linux VPS plans come with full root access and NVMe storage in Mumbai, Europe or the USA, with the same price at renewal. Stuck on a step? Talk to our team on chat, ticket or phone, 24/7 in Hindi and English. Running other self-hosted apps too? Start with our guide to securing a Linux VPS.
Sources: Supabase: Self-Hosting with Docker, Configure reverse proxy and HTTPS, Accessing Postgres, Update your self-hosted deployment.
Frequently asked questions
How much RAM does self-hosted Supabase need?
Supabase lists 4 GB RAM as the minimum and 8 GB or more as recommended for the full Docker stack. An 8 GB VPS is fine for testing and small apps. For a live app with real users, 12 GB leaves room for Postgres, file uploads and your own app.
Is self-hosted Supabase free?
Yes, the software is open source and free to self-host. You pay only for the server. You also take on updates, backups and security yourself.
Why is my Supabase database port open even though my firewall blocks it?
Docker adds its own firewall rules for published ports, and they bypass ufw and firewalld. Bind the ports in docker-compose.yml to 127.0.0.1, for example 127.0.0.1:${POSTGRES_PORT}:5432, and reach the database through an SSH tunnel.
Can I run self-hosted Supabase with aaPanel?
Yes. Add a site in aaPanel for your Supabase subdomain, set a reverse proxy to http://127.0.0.1:8000, and turn on Let's Encrypt SSL there. Don't run a second Nginx or Supabase's Caddy container, because aaPanel already uses ports 80 and 443.
How do I back up self-hosted Supabase?
Run pg_dump inside the database container every night, for example docker compose exec -T db pg_dump -U postgres -Fc postgres, and also back up volumes/storage and your .env file. Keep copies off the server, and take a VPS snapshot before updates.


