Stop Paying for Firebase: How to Self-Host Supabase on DigitalOcean for Free
Building an app or launching a startup used to mean writing backend code from scratch. Then came Firebase, and more recently, Supabase—offering real-time PostgreSQL databases, instant Auth, Storage, and Edge Functions.
But as your application scales, cloud platform limits quickly turn into massive monthly bills. Free tiers run dry, database storage limits kick in, and user authentication pricing starts to compound.
Fortunately, Supabase is open-source. You can host the entire ecosystem yourself—Postgres, Auth, Storage, Realtime, and the Studio GUI—on your own infrastructure.
In this guide, we'll walk through deploying your own production-ready, self-hosted Supabase instance. Best of all, you can do this with zero upfront cost by leveraging DigitalOcean's $200 Free Cloud Credits.
Why Self-Host Supabase?
- No Artificial Database Limits: Pay only for the raw SSD storage of your server, not per-gigabyte premium rates.
- Unlimited Monthly Active Users (MAUs): Stop worrying about hitting user authentication caps.
-
Full Database Control: Direct access to your PostgreSQL database with pre-packaged extensions like
pgvectorfor AI-powered applications. - Data Privacy: Keep all your user and application data strictly isolated on your own virtual private server (VPS).
Step 1: Spin Up Your VPS on DigitalOcean
To run Supabase smoothly (including the Studio UI, Postgres, Kong, and GoTrue), you will need a VPS with at least 2 GB of RAM and 1 vCPU.
- Sign up using the DigitalOcean $200 Free Trial Link to get $200 in free credits (valid for 60 days).
- Create a new Droplet.
- Choose Ubuntu 22.04 LTS or 24.04 LTS as the operating system.
- Select the Basic Plan with a Regular SSD (the $12/month or $18/month tier is highly recommended for development/early production workloads).
- Set up your SSH key for secure login and click Create Droplet.
Step 2: Install Docker and Docker Compose
Once your Droplet is running, connect via SSH:
ssh root@YOUR_DROPLET_IP
Update your packages and install Docker alongside Docker Compose:
sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose git -y
Verify the installation:
docker --version && docker-compose --version
Step 3: Clone and Configure Supabase
Supabase maintains an official Docker repository that pre-configures all necessary microservices. Clone it directly onto your server:
# Clone the repository
git clone --depth 1 https://github.com/supabase/supabase
# Navigate to the docker directory
cd supabase/docker
# Copy the template environment file
cp .env.example .env
Step 4: Secure Your Environment Variables (Critical)
Before launching Supabase, you must update the default API keys and passwords to secure your instance.
Generate high-entropy random keys for your secrets. You can generate a safe string using your terminal:
# Generate a random 32-character string for passwords
openssl rand -hex 32
Open the configuration file:
nano .env
Find and update these specific variables:
-
POSTGRES_PASSWORD: Change this to a highly secure custom password. -
JWT_SECRET: Update this to a secure, custom secret (used for securing user tokens). -
ANON_KEY: Replace this with a newly generated JWT containing anonymous access claims. -
SERVICE_ROLE_KEY: Replace this with a newly generated JWT containing service_role access claims.
(Tip: You can use Supabase's utility tools online to generate matching JWT payloads, or run the container generator tool specified in the Supabase documentation to safely populate the anon/service keys).
Save and exit (Ctrl+O, Enter, Ctrl+X).
Step 5: Boot Up Supabase
With your .env configured, start all the backend services in detached mode:
docker-compose up -d
Docker will now pull the database, auth server, storage manager, API gateway (Kong), and Supabase Studio images. Once finished, run docker ps to verify all services are running stably.
docker ps
Step 6: Access Your Dashboard
By default, the incredible Supabase Studio dashboard is exposed on port 8000.
Open your browser and navigate to:
http://YOUR_DROPLET_IP:8000
You will be greeted with the fully functional, self-hosted Supabase Studio UI! From here, you can manage tables, run SQL queries, view users, and monitor storage buckets.
Step 7: Connect Your App
To connect your web or mobile app (Next.js, React, Flutter, etc.) to your new self-hosted backend, simply swap out the cloud URL and public key in your Supabase Client initialization:
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = 'http://YOUR_DROPLET_IP:8000'
const supabaseAnonKey = 'YOUR_NEW_ANON_KEY'
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
Going to Production: Important Next Steps
While running on a raw IP is fine for development, production environments require a few additional safeguards:
-
Add a Domain and SSL: Set up a reverse proxy like Nginx or Caddy to point your domain (e.g.,
supabase.yourdomain.com) to port8000with automated Let's Encrypt SSL certificates. -
UFW Firewall: Limit access to internal container ports. Ensure only ports
80(HTTP),443(HTTPS), and your SSH port are accessible publicly. -
Backups: Set up a simple cron job to run
pg_dumpon your Postgres database and upload backups to secure cold storage.
Conclusion
Self-hosting Supabase puts the power back in your hands. You get a production-grade, highly reliable, modern Postgres database, real-time sync engine, and authentication layer with no arbitrary API call limits or scaling costs.
Take advantage of DigitalOcean's $200 Free Trial to spin up your instance today and start building restriction-free.
💬 Have questions about securing your self-hosted instance or setting up custom SMTP email servers for your Auth? Let me know in the comments below!
🚀 Enjoyed this guide? Join our community on Telegram to get high-value, self-hosting guides and architectural breakdowns delivered straight to your feed!
Liked this resource? Join our daily Telegram channel for more developer tools and cloud insights: @Libretech2026
Top comments (0)