---
title: "Deploy Ory Kratos"
description: "Ory Kratos 26.2: headless identity and user management API on Postgres."
category: "Authentication"
url: https://railway.com/deploy/ory-kratos
---

# Deploy Ory Kratos

Ory Kratos 26.2: headless identity and user management API on Postgres.

**[Deploy Ory Kratos on Railway](https://railway.com/template/ory-kratos)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/ory-kratos/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Authentication

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### kratos https://github.com/ory.png

- **Image:** oryd/kratos:v26.2.0
- **Health check:** /health/ready
- **Public domain:** Yes

## Documentation

# 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

- [Ory Kratos documentation](https://www.ory.sh/docs/kratos/ory-kratos-intro)
- [Kratos v26.2.0 release](https://github.com/ory/kratos/releases/tag/v26.2.0)
- [Self-service flows](https://www.ory.sh/docs/kratos/self-service)

### 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:

```bash
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.


## Similar templates

- [Keycloak](https://railway.com/deploy/mSwigX) — Keycloak template with keywind theme + apple and discord providers
- [lua-protector](https://railway.com/deploy/lua-protector) — Test deployed my project first
- [bknd](https://railway.com/deploy/p4nTYL) — Feature-rich yet lightweight backend

Open this page in a browser: https://railway.com/deploy/ory-kratos
