Keycloak on Railway
Open-source identity and access management with SSO, OIDC and SAML, running with Postgres on Railway.
Keycloak is an open-source identity and access management server. It provides single sign-on, OAuth 2.0 and OpenID Connect, and SAML 2.0 for your applications, with user federation, social login and multi-factor authentication.
Teams use it as a self-hosted alternative to hosted identity providers such as Auth0 or Okta, keeping realms, users and sessions in their own Postgres database. Common uses are SSO for internal tools, social login, LDAP or Active Directory federation, and protecting APIs with access tokens.
Keycloak is released under the Apache License 2.0.
What Keycloak can do
- Single sign-on over OpenID Connect and SAML 2.0
- Social login and identity brokering
- LDAP and Active Directory federation
- Multi-factor authentication with OTP, WebAuthn and passkeys
- Realms for separating tenants
- Admin console and admin API
What people use it for
- SSO for internal tools and dashboards
- Self-hosted login for a SaaS product
- Social login for web apps
- Protecting APIs with OAuth 2.0 tokens
Videos
Running Keycloak on Railway
The Railway template builds an optimized Keycloak 26 image and runs it with a Railway Postgres database. The hostname follows Railway's public domain, proxy headers are trusted, and an initial admin password is generated. Sessions are stored in Postgres, so restarts do not log users out. Keycloak is a Java server, so cost is driven mainly by the memory the JVM needs and the Postgres volume.
Keycloak templates on Railway
Tracklayer templates are listed first. Other Keycloak templates follow, ordered by total deployments on Railway. How this works.
Deployment numbers as of 2026-11-20.
Questions about Keycloak
How do I log in for the first time?
Open /admin on your domain and sign in with KC_BOOTSTRAP_ADMIN_USERNAME (default admin) and the generated KC_BOOTSTRAP_ADMIN_PASSWORD. Keycloak treats it as temporary, so create a permanent admin in the master realm and delete the temporary one.
What is my issuer URL?
https://your-domain/realms/your-realm. Apps in the same Railway project can use the private address keycloak.railway.internal:8080 for discovery and tokens.
Do password reset e-mails work?
Keycloak sends mail over SMTP only, and Railway allows outbound SMTP on the Pro plan. On other plans, reset and verification e-mails need a relay reachable from Railway.
Can I run more than one replica?
Set KC_CACHE=ispn first so nodes cluster through the database. Never run more than one replica with the default local cache.
How do I upgrade Keycloak?
Back up Postgres, change the KEYCLOAK_VERSION variable and deploy; Keycloak migrates its schema on start.
Guides
Tracklayer maintains the templates marked as such; Keycloak is a trademark of its owners and this site is not affiliated with them.