Skip to main content

Self-Host Supabase: Build Your Own Firebase Alternative with PostgreSQL (2026)

· 6 min read
Yassine El Haddad
Software Developer & Automation Specialist

I build production AI agents, web scrapers, and automation pipelines. Most of what I publish here comes from the actual problems they run into: proxies that get banned, anti-bot stacks that fingerprint your client, RAG that drifts when the underlying data moves. Stack: Python, TypeScript, Go, FastAPI, LangChain, Crawlee, Playwright, deployed on AWS, GCP, and Cloudflare.

Supabase is an open-source Firebase alternative: PostgreSQL database, Auth, Storage, Realtime, and Edge Functions in one stack. Supabase Cloud starts at $25/mo for production — self-hosting on a Liquid Web VPS cuts costs and gives you data sovereignty and full control. This guide covers server requirements, installation, configuration, SSL, migration from cloud, and maintenance.

What Is Supabase?

Supabase provides:

  • PostgreSQL — Full SQL, Row Level Security (RLS), extensions
  • Auth — Email, OAuth, magic links (GoTrue)
  • Storage — S3-compatible file storage
  • Realtime — WebSocket subscriptions for DB changes
  • Edge Functions — Deno-based serverless (optional)

It's a Batteries-included backend. The client SDKs match Firebase's ergonomics but use PostgreSQL under the hood.

Why Self-Host?

  • Cost — Cloud Pro is $25/mo; a VPS can run the stack for less
  • Data sovereignty — Data stays on your infrastructure
  • Control — Tune PostgreSQL, add extensions, customize Auth
  • Compliance — Meet regional or industry requirements

Trade-off: You manage backups, updates, and scaling. Use a Liquid Web VPS for managed monitoring and SSD performance.

Server Requirements

ResourceMinimumRecommended
RAM4 GB8 GB
CPU2 cores4 cores
Storage20 GB SSD40+ GB SSD
OSUbuntu 22.04Ubuntu 24.04

PostgreSQL performance is I/O-bound. SSD is essential. For production with Realtime and Storage, 8 GB RAM is safer.

Setup

Clone and configure

git clone --depth 1 https://github.com/supabase/supabase
cd supabase/docker
cp .env.example .env

Edit .env:

  • POSTGRES_PASSWORD — Strong password for PostgreSQL
  • JWT_SECRET — Generate with openssl rand -base64 32
  • ANON_KEY and SERVICE_ROLE_KEY — Use Supabase CLI or generate from JWT
  • API_URL — Your public URL (e.g. https://supabase.yourdomain.com)
  • SITE_URL — Frontend URL for Auth redirects

Start services

docker compose up -d

Wait for services to be healthy: docker compose ps. Core services include PostgreSQL, Kong (API gateway), GoTrue (Auth), Realtime, Storage, PostgREST, and others.

Configure Kong, GoTrue, Realtime, Storage

Kong routes traffic to PostgREST, GoTrue, Realtime, and Storage. Set KONG_HTTP_PORT and URLs in .env so Kong can reach each service.

GoTrue — Set GOTRU_* vars for site URL, redirect URLs, and JWT.

Realtime — Uses WebSocket. Ensure your reverse proxy (Traefik or Nginx) supports WebSocket (Connection: Upgrade, Upgrade: websocket).

Storage — Default is local filesystem. For S3: set STORAGE_BACKEND=s3 and AWS credentials. Useful for multi-instance or large files.

SSL with Traefik or Nginx

Put Traefik in front of Kong:

labels:
- "traefik.http.routers.supabase.rule=Host(`supabase.yourdomain.com`)"
- "traefik.http.routers.supabase.tls.certresolver=letsencrypt"
- "traefik.http.services.supabase.loadbalancer.server.port=8000"

Use Let's Encrypt for certificates. For Realtime, ensure Traefik passes WebSocket headers. See the Traefik guide for middleware and headers.

Migrating from Supabase Cloud

  1. Exportpg_dump from your cloud project (Supabase dashboard → Database → Backups, or direct connection).
  2. Importpg_restore into your self-hosted PostgreSQL.
  3. Update client — Change SUPABASE_URL and SUPABASE_ANON_KEY to your self-hosted Kong URL and keys.
  4. Storage — If using Storage, migrate files to your self-hosted Storage or S3.

Maintenance: Backups and Monitoring

  • Backups — Run pg_dump daily. Store off-server (S3, backup service).
  • Monitoring — Use pg_stat_statements for slow queries. Monitor container health and disk usage. Liquid Web provides proactive monitoring.
  • Updates — Pull latest Supabase images periodically. Test in staging before production.

Self-Hosted Supabase vs Cloud vs Alternatives

FeatureSelf-Hosted SupabaseSupabase CloudPlanetScaleNeon
CostVPS only$25+/moServerless pricingServerless pricing
PostgreSQLFullFullMySQL (Vitess)PostgreSQL
AuthGoTrueGoTrueExternalExternal
RealtimeYesYesNoLimited
Data locationYour serverSupabase regionsPlanetScaleNeon regions
MaintenanceYouManagedManagedManaged
Best forCost, sovereigntyEase, scaleMySQL serverlessPG serverless

Self-host when cost and control matter. Use Cloud when you want zero-ops. Pair self-hosted Supabase with Docker Compose production patterns and VPS hardening for a robust backend. Add Traefik for TLS and routing.

Apify Affiliate Banner 728x90Apify Affiliate Banner 728x90Apify Affiliate Banner 300x50Apify Affiliate Banner 300x50
Start with defaults

Use default Storage (local) and Realtime config first. Add S3 and tune PostgreSQL once the stack is stable. Incremental customization reduces debugging.

Frequently Asked Questions

VPS cost only: roughly $15–40/mo for 4–8 GB RAM. Supabase Cloud Pro is $25/mo. Self-hosting saves money at scale and gives full control.

Yes. Edge Functions run as Deno containers. Configure in docker-compose. You manage scaling and deployment.

Use pg_dump for PostgreSQL. Schedule daily dumps to S3 or backup storage. For Storage, sync files to S3 or another backup destination.

Yes. The client SDKs connect to your Kong URL and use the same API. Update SUPABASE_URL and SUPABASE_ANON_KEY in your app.

WebSocket requires Connection: Upgrade and Upgrade: websocket headers. Ensure Traefik or Nginx passes these through. Check Realtime container logs for errors.

Common mistakes and fixes

Supabase containers fail to start

Ensure 4+ GB RAM. Check Docker logs: docker compose logs. Verify .env has all required vars. PostgreSQL needs sufficient shared_buffers; reduce if OOM.

Kong API gateway returns 502

Kong depends on auth and rest. Ensure all core services are healthy. Check docker compose ps. Restart Kong after other services are up.

Realtime not working

Verify REALTIME_URL and websocket URL in client. Check Realtime container logs. Ensure Traefik/Nginx proxies WebSocket correctly (Upgrade, Connection headers).