
Deploy Ory Kratos
Ory Kratos 26.2: headless identity and user management API on Postgres.
Just deployed
/var/lib/postgresql/data
kratos
Just deployed
Deploy and Host Ory Kratos on Railway
Ory Kratos is an open-source identity and user management server. It provides registration, login, sessions, profile settings and account recovery through an API, and leaves the user interface to you. Apps, single-page apps and mobile clients call its flows directly, so you own the login experience without writing password handling.
About Hosting Ory Kratos
This template runs the official oryd/kratos:v26.2.0 image with a Railway Postgres database. A pre-deploy step runs the SQL migrations and retries until the database is reachable. The public API is on an HTTPS domain, and the admin API stays on the private network, because it has no authentication of its own. Identities use an email and password schema, and a session starts right after registration. Railway blocks outgoing SMTP, so email verification and account recovery are switched off; enable them once you configure a courier. All settings come from environment variables, with the identity schema embedded as base64.
Common Use Cases
- Login and registration for mobile apps and SPAs through Kratos API flows
- A self-hosted identity backend behind your own custom login pages
- Central user management for several services through the admin API
Dependencies for Ory Kratos Hosting
oryd/kratos:v26.2.0(official image)- Railway Postgres for identities and sessions
Deployment Dependencies
Implementation Details
| Service | Source | Networking | Storage |
|---|---|---|---|
| kratos | oryd/kratos:v26.2.0 | public API on HTTPS (4433), admin API private (4434) | Postgres |
| Postgres | Railway Postgres | private | volume |
| Variable | Purpose |
|---|---|
KRATOS_PUBLIC_URL | Public API for your clients |
KRATOS_ADMIN_URL | http://kratos.railway.internal:4434 for your backend |
IDENTITY_SCHEMAS_0_URL | Identity schema (base64://...); replace it to add traits |
SECRETS_COOKIE_0, SECRETS_CIPHER_0, SECRETS_DEFAULT_0 | Generated secrets |
SELFSERVICE_FLOWS_VERIFICATION_ENABLED, ..._RECOVERY_ENABLED | false until you set up email |
API flow example:
FLOW=$(curl -s "$KRATOS_PUBLIC_URL/self-service/registration/api" | jq -r .id)
curl -s -XPOST "$KRATOS_PUBLIC_URL/self-service/registration?flow=$FLOW" -H 'Content-Type: application/json' \
-d '{"method":"password","password":"","traits":{"email":"you@example.com"}}'
Browser flows set cookies and redirect to your login pages (SELFSERVICE_FLOWS_LOGIN_UI_URL and friends), which need to be on the same site as Kratos; in practice, give both a custom domain. Kratos can send email through an HTTP API instead of SMTP; see its courier documentation.
This is a community-maintained deployment package and does not imply affiliation with or endorsement by Ory Corp.
Why Deploy Ory Kratos on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Ory Kratos on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content


