uploads module. Mail goes through Resend and logs go to an external OTLP collector.
Every deploy runs the same way:
railway.toml
The project ships the intended Railway settings in railway.toml:
railway.toml
Before you start
You need:- the project in a GitHub repository;
- a Resend account with an API key and a verified sender domain;
- an OTLP collector for logs (see Logging and observability);
- a local checkout after
npm install, and the Railway CLI logged in withrailway login.
First deploy
1
Commit your migrations
The kit doesn’t ship migrations. If Check with
prisma/migrations/ is empty, create one and commit the whole folder:git ls-files prisma/migrations: it should list migration_lock.toml and at least one migration.sql.2
Create the Railway project
Create a project with a PostgreSQL service and an app service connected to your GitHub repository. Railway deploys the app on every push to the connected branch.
3
Add a domain and variables
In the app service’s networking settings, generate a Railway domain or attach your own. Then set the variables from the table below, with
APP_URL set to that domain including https://.If you use the uploads module, set up storage now: a bucket or a volume. See File storage.Keep AUTH_PUBLIC_SIGNUP unset or false until you’ve created the accounts in step 7. See why.4
Configure deploy settings
In the app service’s settings, enter the values from
railway.toml:- Pre-deploy command:
npx prisma migrate deploy - Healthcheck path:
/api/healthcheck, timeout 10 seconds - Restart policy: on failure, max 3 retries
CMD is node server.js.5
Deploy
Trigger a deploy or push to the connected branch.
6
Check the migration log
Open the deploy logs and find the output of
prisma migrate deploy. You want All migrations have been successfully applied. or No pending migrations to apply.If you see No migration found in prisma/migrations, the migrations didn’t reach the image. The command exits 0 and the healthcheck passes on an empty database, so this is easy to miss. Go back to step 1. For other errors (P3005, P3018), see Migrations on deploy.7
Create the accounts
Right after the first successful deploy, create the first accounts with
railway run, as described in Create the first accounts.8
Check it by hand
The healthcheck only proves the process started and reached the database. Open the app at
APP_URL and:- sign in with an account from step 7. This confirms
APP_URLmatches the address you use; better-auth rejects requests from other origins; - open a default-locale URL without a prefix, such as
/sign-in, and confirm it renders instead of redirecting in a loop; - request a password reset and confirm the email arrives. This checks
RESEND_API_KEYandEMAIL_FROM; - confirm log export. Sign-in and page views don’t log anything, so trigger an action that does: as the service account, use Sign in as on the client admin’s row on the Users page, then Back to my account. Your collector should show
[USERS] Impersonation startedand[USERS] Impersonation stopped.
Production variables
Set these on the app service. The server validates them at startup and exits if anything is wrong, so a new value only takes effect after a redeploy. Full reference: Environment variables.
Don’t set:
SMTP_URL: if present, it wins over Resend, also in production.NODE_ENV,PORT,HOSTNAME: the Dockerfile sets them and Railway injectsPORT. If you setPORTyourself, Railway uses it for the healthcheck too.ADMIN_EMAIL,ADMIN_PASSWORD: onlyadmin:createreads them, and on the service they’d leak into everyrailway run.LOG_LEVEL: it has no effect.
When variables are wrong, the new container prints a report to stderr (
Nieprawidłowe zmienne środowiskowe (N): followed by one line per problem) and exits with code 1. The healthcheck fails and traffic stays on the previous version. Restarts won’t help, since each start fails the same way. The report goes through console.error, so it shows up in the deploy logs even without OTLP export.Create the first accounts
The image doesn’t includescripts/ or dev dependencies, so admin:create can’t run in the container. Instead, railway run <command> runs a command on your machine with the service’s variables. The script uses your local checkout, node_modules and Prisma client.
The app’s DATABASE_URL points to Railway’s private network (*.railway.internal), which your machine can’t reach. Give the script the database’s public URL:
1
Enable public access to Postgres
In the PostgreSQL service’s networking settings, enable public networking. Railway creates a TCP proxy and a
DATABASE_PUBLIC_URL variable on the database service. Traffic through it is billed as egress.2
Reference it from the app service
On the app service, add
DATABASE_PUBLIC_URL with the value ${{Postgres.DATABASE_PUBLIC_URL}}. railway run only loads one service’s variables, so without this reference the variable is empty.3
Match your checkout to production
Check out the commit that runs in production and generate the Prisma client with
npm install (or npm run db:generate if dependencies didn’t change). The client is built from the local schema, which must match the database.4
Check where the password comes from
The script loads
.env.local and .env with dotenv, which doesn’t override variables already set. Railway’s values win, but anything the service lacks is read from your local files. A non-empty ADMIN_PASSWORD in your local .env would become the production password. Leave it empty to get a generated one.5
Run admin:create
From the project root, linked to the app service with Put options such as
railway link:--role superadmin and --org-name "Acme" after --email, inside the single quotes. The script prints the generated password once; sign in with it before you close the terminal.6
Close public access
When you no longer need outside access, remove the
DATABASE_PUBLIC_URL reference and disable public networking on the database.Why sign-up stays closed
Untiladmin:create runs, the database has no organization. What happens if someone signs up before that:
Keep
AUTH_PUBLIC_SIGNUP=false until the accounts exist, then set the final flags.
CI and deploys
Railway deploys on push regardless of CI results. To gate deploys on CI, enable Railway’s Wait for CI option on the service: the deploy waits for the GitHub Actions workflows triggered for that commit and is skipped if any fail. See CI workflows.Related
Handover
Service accounts, client admin, and ending support access.
File storage
Railway Bucket or volume for the uploads module.
Docker
What the image contains and how migrations run.
Environment variables
Full variable reference.