Skip to content

Railway

Tested with: Railway CLI 3.x · Railway services (Nixpacks / Dockerfile) · PostgreSQL 17

  1. Add the connection string as a service variable (or a shared variable if several services use it).

    shell
    railway variables --set 'DATABASE_URL=postgresql://app:<password>@pg-7f3k.us-east.databasezy.com:5432/app?sslmode=verify-full'
  2. Enable Static Outbound IPs on the service (a Railway Pro plan feature) and allow them.

    shell
    zb api PUT /v1/orgs/{org}/instances/pg-7f3k/network -d '{"allow_cidrs": ["203.0.113.10/32", "203.0.113.11/32"]}' # replaces the list
  3. Run migrations in the pre-deploy command (Settings → Deploy → Pre-deploy command): npx prisma migrate deploy.

zb migrate --from "$RAILWAY_DATABASE_URL" --to inst_abc detects the Railway preset (public TCP proxy, SSL mode) and runs the copy from the Databasezy cell. See the Railway migration guide.