Railway
Deploy the node target to Railway straight from your Git repo, with managed Postgres and Redis services and the schema migrating on every boot.
Railway builds and runs the node target directly from your Git repo. It runs the same long-running Docker image documented in Self-hosting with Docker, so both fullstack and separate work and there is no Railway-specific code in the boilerplate.
Deploy
Point the service at the owner Dockerfile - the frontend app's for fullstack, apps/backend/Dockerfile (EXPOSE 3010) for separate. Its CMD is pnpm start, with pnpm -F @repo/database run deploy prepended by the CLI, so the schema migrates on every boot.
For a frontend image, set NEXT_PUBLIC_API_URL=https://yourdomain.com/api as a service variable before the first build - Railway exposes variables to Docker builds as build args, and Next.js bakes it into the browser bundle at build time (see Self-hosting with Docker).
DATABASE_URL, or supply an external one (Neon or Supabase). Add a Redis service for REDIS_URL, or use Upstash.${{ }} syntax, e.g. ${{ Postgres.DATABASE_URL }}.pnpm start; the schema migrates before the server binds. Later Git pushes redeploy automatically.Required environment variables
DATABASE_URL only needs to live on the schema-owner service. Full list in Environment variables.
| Variable | Required | Source |
|---|---|---|
DATABASE_URL | Yes | Postgres service, or external Neon / Supabase |
REDIS_URL | Yes | Redis service, or self-hosted / Upstash (Caching) |
BETTER_AUTH_SECRET | Yes | 32+ char random secret (openssl rand -base64 32) |
API_URL | Yes | The backend's public URL; falls back to the public API URL var |
INNGEST_APP_ID, INNGEST_EVENT_KEY, INNGEST_BASE_URL | Yes | Background jobs |
BASE_URL, TRUSTED_ORIGINS | Recommended | Production origin, plus comma-separated origins for auth and CORS |
TRUSTED_PROXY | Not needed | Railway's edge is detected from its own variables - verify per Client IP |
Never deploy a --demo build to Railway - its schema step resets the database and force-pushes the schema on every restart.
The container's HEALTHCHECK probes the listening port with a generous start period, so Railway holds traffic until the boot-time migration finishes - no manual readiness gate needed.
Environment variables
The full set of production env vars to set on the Railway service.
Reverse proxy
Front the apps by host and path when running a separate backend.
Separate backend
Run the standalone Hono server on API_PORT for independent scaling.
Going to production
The pre-launch checklist of secrets, webhooks, and migrations.