Supabase Self-Hosted Backend
Self-hosted Supabase on Railway: Postgres 17 with Supabase extensions, Auth, REST and GraphQL APIs, Realtime, Storage, Edge Functions, the Supavisor pooler and Studio. The template follows the official self-hosted v0.8.2 Docker setup, and only the API gateway is public.
What you get
- About a dozen services: Envoy gateway, Postgres, Studio, Auth (GoTrue), PostgREST, Realtime, Storage API, imgproxy, postgres-meta, Edge Runtime and Supavisor
- Postgres 17.6 with a persistent volume
- Storage objects kept in a Railway Bucket instead of local disk
- Anon and service_role keys derived from one generated secret, with no manual setup
- Studio behind basic auth on the gateway domain, and Edge Functions deployed from services/functions/functions in your repo
Good for
- A backend for web and mobile apps: Postgres, row-level security, auth and file uploads behind one URL
- Projects with data residency or compliance needs that rule out a shared cloud project
- Realtime features such as chat, live dashboards and presence on your own infrastructure
- Staging environments that mirror a Supabase Cloud project
Services in this template
- Realtime · image
supabase/realtime:v2.134.10 - Storage · from
baranberkay96/supabase-railway - Functions · from
baranberkay96/supabase-railway - Gateway · from
baranberkay96/supabase-railway - Studio · from
baranberkay96/supabase-railway - Postgres · from
baranberkay96/supabase-railway - Meta · image
supabase/postgres-meta:v0.99.0 - Supavisor · from
baranberkay96/supabase-railway - imgproxy · image
darthsim/imgproxy:v3.31.4 - REST · image
postgrest/postgrest:v14.17 - Auth · image
supabase/gotrue:v2.196.0
Questions people ask
How do I log in and get my API keys?
Open the Gateway public domain and sign in with DASHBOARD_USERNAME and DASHBOARD_PASSWORD from the Gateway Variables tab. Keys are under Studio, Project Settings, API, and the anon key also appears in the Gateway deploy log. Use the Gateway URL as SUPABASE_URL.
What should I configure after deploying?
Set GOTRUE_SITE_URL and GOTRUE_URI_ALLOW_LIST on Auth to your app URL. Configure SMTP on Auth, then set GOTRUE_MAILER_AUTOCONFIRM=false so new users must confirm their e-mail.
Is the database reachable from outside?
Not by default. Apps on Railway use DATABASE_URL from Postgres or POOLER_URL_TRANSACTION from Supavisor. Adding a TCP proxy sends unencrypted Postgres traffic over the internet.
What drives the cost?
You pay for each of the roughly dozen services separately, so RAM and CPU add up across them. Postgres is the usual bottleneck. The source documents give no measured figures, so check usage in your own project.
How do I upgrade?
Image tags follow one upstream release. Compare the next release in Supabase's self-hosted changelog, update the tags and apply any config changes it lists. Do not change POSTGRES_PASSWORD, JWT_SECRET or PGSODIUM_ROOT_KEY after the first deploy unless you follow Supabase's rotation guides.
Full template README
Deploy and Host Supabase with Railway
Run your own Supabase on Railway: Postgres 17 with Supabase extensions, Auth, auto-generated REST and GraphQL APIs, Realtime, Storage backed by a Railway Bucket, Edge Functions, the Supavisor pooler and Studio. Keys are generated on deploy with no manual setup, and only the API gateway is public. Community template.
About Hosting Supabase
Self-hosted Supabase is not one container. It is about a dozen cooperating services that must share one JWT secret and matching API keys, reach Postgres over a private network, and sit behind a gateway that checks API keys and protects the dashboard. This template follows the official supabase/supabase Docker setup (release self-hosted/v0.8.2) and adapts it to Railway: init scripts and gateway config are baked into images instead of bind mounts, files go to a Railway Bucket instead of a local disk, each service listens on IPv6 and IPv4 for Railway's private network, and the anon and service_role keys are derived from one generated secret when each service starts.
Common Use Cases
- Backend for web and mobile apps: Postgres, row-level security, auth and file uploads behind one URL
- Data residency or compliance needs that rule out a shared cloud project
- Realtime features (chat, live dashboards, presence) on your own infrastructure
- Internal tools that need an admin UI (Studio) plus an instant REST/GraphQL API
- Staging environments that mirror a Supabase Cloud project
Dependencies for Supabase Hosting
- Postgres (
supabase/postgres17.6) with a persistent volume - Railway Bucket for Storage objects
- Envoy API gateway, GoTrue (Auth), PostgREST, Realtime, Storage API, imgproxy, postgres-meta, Edge Runtime, Supavisor, Studio
Deployment Dependencies
- Supabase self-hosting guide: https://supabase.com/docs/guides/self-hosting/docker
- Upstream Docker files: https://github.com/supabase/supabase/tree/master/docker
- Self-hosted changelog: https://github.com/supabase/supabase/blob/master/docker/CHANGELOG.md
- API keys for self-hosting: https://supabase.com/docs/guides/self-hosting/self-hosted-auth-keys
- Railway Buckets: https://docs.railway.com/guides/storage-buckets
Implementation Details
| Service | Image | Role |
|---|---|---|
| Gateway | envoyproxy/envoy:v1.39.1 + template config |
Only public service: routes /auth/v1, /rest/v1, /graphql/v1, /realtime/v1, /storage/v1, /functions/v1, /pg; Studio at / behind basic auth |
| Postgres | supabase/postgres:17.6.1.136 + init scripts |
Database, volume /var/lib/postgresql/data |
| Studio | supabase/studio:2026.09.07-sha-7996410 |
Dashboard, SQL snippets on a volume |
| Auth | supabase/gotrue:v2.196.0 |
Sign-up, sign-in, JWTs |
| REST | postgrest/postgrest:v14.17 |
REST + GraphQL over Postgres |
| Realtime | supabase/realtime:v2.134.10 |
Database changes, broadcast, presence |
| Storage | supabase/storage-api:v1.74.0 |
Files in the Railway Bucket |
| imgproxy | darthsim/imgproxy:v3.31.4 |
Image resizing |
| Meta | supabase/postgres-meta:v0.99.0 |
Schema API for Studio |
| Functions | supabase/edge-runtime:v1.76.2 |
Edge Functions from services/functions/functions |
| Supavisor | supabase/supavisor:2.9.12 |
Connection pooler (private network) |
First login
- Deploy. No input is required. Wait until all services are healthy (Postgres initialises on the first boot).
- Open the Gateway's public domain. Log in with
DASHBOARD_USERNAME/DASHBOARD_PASSWORDfrom the Gateway service's Variables tab. - Get your keys: Studio → Project Settings → API, or the Gateway deploy log (anon key only). Use the Gateway URL as
SUPABASE_URLin supabase-js. - Set
GOTRUE_SITE_URL(andGOTRUE_URI_ALLOW_LIST) on the Auth service to your app's URL. Configure SMTP on Auth, then setGOTRUE_MAILER_AUTOCONFIRM=falseso new users must confirm their email.
Database access: apps on Railway use DATABASE_URL from the Postgres service (direct) or POOLER_URL_TRANSACTION from Supavisor (pooled). Nothing is exposed publicly by default; adding a TCP proxy sends unencrypted Postgres traffic over the internet.
Edge Functions: add services/functions/functions/{name}/index.ts in your repository and push; Railway rebuilds the Functions service. Call it at /functions/v1/{name}. Set VERIFY_JWT=true on Functions to require a valid JWT.
Optional new API keys: run upstream docker/utils/add-new-auth-keys.sh locally with your JWT_SECRET, then set SUPABASE_PUBLISHABLE_KEY, SUPABASE_SECRET_KEY, ANON_KEY_ASYMMETRIC, SERVICE_ROLE_KEY_ASYMMETRIC on the Gateway, GOTRUE_JWT_KEYS (JWT_KEYS) on Auth, and the public JWKS as PGRST_JWT_SECRET (REST), API_JWT_JWKS (Realtime), JWT_JWKS (Storage) and SUPABASE_JWKS (Functions).
Scaling: raise memory/CPU per service in Railway. Postgres is the usual bottleneck; tune pool sizes on Supavisor. Stateless services (Auth, REST, Realtime, Storage, imgproxy, Functions) can be given more resources independently.
Pinning and upgrades: image tags follow one upstream release. To upgrade, compare the next release in the upstream changelog, update the tags (image services in Railway, FROM lines in services/*/Dockerfile) and apply any listed config changes. Do not change POSTGRES_PASSWORD, JWT_SECRET or PGSODIUM_ROOT_KEY after the first deploy unless you follow the upstream rotation guides.
Why Deploy Supabase on Railway?
Railway runs each Supabase component as its own service on a private network, with volumes, a managed bucket, generated secrets and per-second billing. You get the full self-hosted stack with keys already wired, and you can resize, redeploy or roll back each component independently instead of managing a VM and Docker Compose yourself.
Guides for this template
View Supabase Self-Hosted Backend on railway.com
Similar templates
| Template | Category | DeploymentsDeploys |
|---|---|---|
| Node.js A minimal Node.js web application. | Starters | 21,948 |
| Django A simple Django application | Starters | 10,302 |
| Flask A minimal Flask application | Starters | 10,100 |
| FastAPI Web framework for developing RESTful APIs in Python | Starters | 7,022 |
| Laravel An example Laravel application | Starters | 5,211 |
| Medusajs 2.0 + Next.js Storefront Full ecommerce solution, manage products, inventory, orders, etc. | Starters | 3,249 |