kratos serve command starts the Ory Kratos server, which includes both the public and admin HTTP APIs.
Usage
Description
This command starts the Kratos server with both the public-facing API (for identity flows like login, registration, etc.) and the admin API (for identity management). The server reads its configuration from a YAML configuration file. The serve command initializes:- Public API - Handles self-service flows (login, registration, settings, recovery, verification)
- Admin API - Provides identity management endpoints
- Message courier - Optionally runs as a background task for sending emails
Flags
Configuration
- --config
- --config-dir
Path to the configuration file.
Development flags
--dev
Disables critical security features to make development easier.
DO NOT USE IN PRODUCTION!This flag disables security features including CSRF protection and other safeguards. It should only be used in development environments.
Telemetry
--sqa-opt-out
Disable anonymized telemetry reports.
Courier
--watch-courier
Run the message courier as a background task to simplify single-instance setup.
kratos courier watch process.
In production deployments with multiple instances, it’s recommended to run the courier as a separate process to avoid duplicate email sends.
Examples
Basic server start
Start the server with a configuration file:Development mode
Run the server in development mode with the courier enabled:Production deployment
Run the server in production with telemetry disabled:Docker deployment
Server endpoints
When the server starts, it exposes two sets of endpoints:Public API (default: port 4433)
The public API is used by your application’s frontend:/self-service/login/*- Login flows/self-service/registration/*- Registration flows/self-service/settings/*- Settings flows/self-service/recovery/*- Account recovery flows/self-service/verification/*- Email verification flows/sessions/whoami- Get current session information/health/alive- Liveness check/health/ready- Readiness check
Admin API (default: port 4434)
The admin API is used for identity management:/admin/identities- Identity CRUD operations/admin/recovery/link- Create recovery links/admin/schemas- Identity schemas/health/alive- Liveness check/health/ready- Readiness check/metrics/prometheus- Prometheus metrics
Configuration
The serve command requires a configuration file. Here’s a minimal example:Health checks
The serve command exposes health check endpoints for monitoring:Liveness probe
200 OK if the server is running.
Readiness probe
200 OK if the server is ready to accept requests (database connection is healthy, migrations are complete, etc.).
Graceful shutdown
The server supports graceful shutdown with a default timeout of 120 seconds. When receiving a termination signal (SIGTERM or SIGINT), the server will:- Stop accepting new requests
- Wait for active requests to complete (up to 120 seconds)
- Close database connections
- Exit
Troubleshooting
Server won’t start
Check that:- Configuration file exists and is valid YAML
- Database connection string is correct (if using a database)
- Ports 4433 and 4434 are not in use
- Required environment variables are set
Version mismatch warning
If you see:Missing version warning
If you see:version field to your configuration file:
See also
- Configuration reference - Complete configuration options
- Identity schemas - Define identity data structures
- Self-service flows - Configure login, registration, and other flows
- Deployment guide - Production deployment best practices