Why Self-Host Supabase?
Self-hosting Supabase on a VPS gives you full control over your backend at a fraction of the cost of Supabase Cloud. A $40/month DigitalOcean or Hetzner droplet can comfortably serve thousands of users — something that would cost $200+ on Supabase Cloud.
Prerequisites
- A VPS with at least 2 CPU cores and 4GB RAM (recommended: 4 cores, 8GB)
- Ubuntu 22.04 LTS (recommended)
- A domain name pointed to your server
- Basic Linux command-line knowledge
Step 1: Prepare Your Server
# Update packages
sudo apt update && sudo apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Install Docker Compose
sudo apt install docker-compose-plugin -y
Step 2: Clone the Supabase Repository
git clone --depth 1 https://github.com/supabase/supabase
cd supabase/docker
cp .env.example .env
Step 3: Configure Environment Variables
Edit the .env file with your secrets:
# Generate these with: openssl rand -base64 32
POSTGRES_PASSWORD=your-strong-postgres-password
JWT_SECRET=your-jwt-secret-at-least-32-chars
ANON_KEY=your-anon-key
SERVICE_ROLE_KEY=your-service-role-key
# Your domain
SITE_URL=https://app.yourdomain.com
API_EXTERNAL_URL=https://api.yourdomain.com
Step 4: Start Supabase
docker compose up -d
This starts all Supabase services: PostgreSQL, PostgREST, GoTrue (Auth), Realtime, Storage, and the Studio dashboard.
Step 5: Set Up Nginx Reverse Proxy
sudo apt install nginx certbot python3-certbot-nginx -y
Configure Nginx to proxy requests to your Supabase instance, then get an SSL certificate:
sudo certbot --nginx -d api.yourdomain.com
Step 6: Configure Your Application
Update your app's environment variables to point to your self-hosted instance:
NEXT_PUBLIC_SUPABASE_URL=https://api.yourdomain.com
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
Step 7: Set Up Automated Backups
# Daily backup cron
0 2 * * * pg_dump -U postgres supabase | gzip > /backups/supabase-$(date +%Y%m%d).sql.gz
Maintenance Tips
- Update Supabase regularly:
git pull && docker compose up -d --pull always - Monitor disk space — database and storage grow over time
- Set up uptime monitoring with UptimeRobot or Grafana
If you're migrating from Lovable Cloud and want this set up professionally with zero downtime, our team handles the complete migration and self-hosted deployment.
Categorized In
Frequently Asked Questions
What VPS provider is best for self-hosting Supabase?
Hetzner (Europe), DigitalOcean, and Vultr all work great. Hetzner offers the best price-to-performance ratio starting at ~$5/month for small projects.
Can I use self-hosted Supabase with a Next.js app?
Yes, just point your NEXT_PUBLIC_SUPABASE_URL to your self-hosted instance. The Supabase JS client works identically.
How do I update self-hosted Supabase to a new version?
Run git pull in the supabase/docker directory, then docker compose up -d --pull always. Always back up before updating.
Share This Intelligence
Start Your Migration Strategy
Don't let vendor lock-in stifle your growth. Get a professional roadmap to Supabase excellence today.
Free Architectural Audit