Self-host Supabase on Railway for a Lovable or Bolt app

By Tracklayer · Updated 2026-11-20

Short answer: deploy a self-hosted Supabase template on Railway and point your app’s SUPABASE_URL at its gateway. Tracklayer’s Supabase Self-Hosted Backend template runs Postgres 17, Auth, REST and GraphQL APIs, Realtime, Storage, Edge Functions, the Supavisor pooler and Studio as about a dozen Railway services. Keys are generated at deploy, and only the API gateway is public.

Deploy Supabase on Railway

When to run your own Supabase

If you build apps with AI tools such as Lovable or Bolt, the backend is often a hosted Supabase project. Running your own copy makes sense when:

The template’s sources do not say how any specific AI app builder connects to it. The client side is the standard one: use the Gateway URL as SUPABASE_URL in supabase-js together with your keys. Check your tool’s own documentation for where it reads those values.

Self-hosted Supabase is not one container. It is about a dozen services that must share one JWT secret and matching API keys. That wiring is what a template saves you from doing by hand.

Which Supabase templates people deploy on Railway

TemplateCreatorDeploymentsServices
DirectusMedim's Projects3,2943
SupabaseSix97210
Supabase Self-Hosted BackendTracklayer1611

Railway marketplace data as of 2026-11-19. Full ranking: Best Supabase templates on Railway.

Names on the marketplace do not always show which Supabase release a template follows, whether the database is kept across restarts, or where Storage files go. Open the template page and check its services before deploying.

Deploy Supabase on Railway, step by step

These steps use Tracklayer’s Supabase Self-Hosted Backend template, which follows the official supabase/supabase Docker setup, release self-hosted/v0.8.2.

  1. Deploy the template. No input is required. Wait until all services are healthy. Postgres initialises on the first boot.
  2. Open the Gateway public domain. Sign in with DASHBOARD_USERNAME and DASHBOARD_PASSWORD from the Gateway service’s Variables tab. Studio sits behind this basic auth.
  3. Get your keys. Go to Studio, Project Settings, API. The Gateway deploy log also prints the anon key. The anon and service_role keys are derived from one generated secret when each service starts.
  4. Point your app at it. Use the Gateway URL as SUPABASE_URL in supabase-js.
  5. Set the Auth URLs. On the Auth service, set GOTRUE_SITE_URL and GOTRUE_URI_ALLOW_LIST to your app’s URL.
  6. Configure email. Set up SMTP on Auth, then set GOTRUE_MAILER_AUTOCONFIRM=false so new users must confirm their email.

What is stored where

The template does not include Supabase’s optional analytics and log collection, which relies on the Docker socket that Railway does not expose.

Connecting other services and Edge Functions

Apps on Railway can use DATABASE_URL from the Postgres service for a direct connection, or POOLER_URL_TRANSACTION from Supavisor for pooled connections. Nothing is exposed publicly by default.

For Edge Functions, add services/functions/functions/{name}/index.ts to your repository and push. Railway rebuilds the Functions service, and you call it at /functions/v1/{name}. Set VERIFY_JWT=true on Functions to require a valid JWT.

Costs

Railway bills usage, and this stack runs about eleven services plus a bucket, so memory adds up across them. The template’s own resource table estimates about 1.2 GB of RAM idle and about 2.3 GB under typical load, with 2 to 5 GB of volume. At Railway’s unit prices that is roughly $15 to $16 per month idle and about $40 per month for a typical production app, plus Bucket storage and egress.

These are estimates, not measurements. Postgres is the usual bottleneck, so it is the first service to give more memory. The template lists Hobby as the minimum plan and Pro for larger databases.

Upgrades and limits

Other options

Compare the full ranking of Supabase templates on Railway. If you only need a database, see PostgreSQL templates. For a broader view, browse all guides.

FAQ

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. The 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 in supabase-js.

Is the database reachable from outside Railway?

Not by default. Apps on Railway use DATABASE_URL from Postgres or POOLER_URL_TRANSACTION from Supavisor over the private network. Adding a TCP proxy sends unencrypted Postgres traffic over the internet, so avoid it unless you understand the risk.

What does it cost?

The template's own estimate is about $15 to $16 per month for an idle or development project and about $40 per month for a typical production app with moderate traffic, plus Bucket storage and egress. These are estimates from Railway's published unit prices, not measurements. The minimum plan is Hobby.

How do I upgrade Supabase?

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.