---
title: "Deploy Keygen"
description: "Keygen CE 1.7: software licensing and license-key validation API."
category: "Other"
url: https://railway.com/deploy/keygen-1
---

# Deploy Keygen

Keygen CE 1.7: software licensing and license-key validation API.

**[Deploy Keygen on Railway](https://railway.com/template/keygen-1)**

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

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

## Template content

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

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

### keygen https://github.com/keygen-sh.png

- **Image:** keygen/api:v1.7.2
- **Health check:** /v1/health
- **Public domain:** Yes

### keygen-worker https://github.com/keygen-sh.png

- **Image:** keygen/api:v1.7.2
- **Start command:** `/app/scripts/entrypoint.sh worker`

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Documentation

# Deploy and Host Keygen on Railway

Keygen is a software licensing and distribution API. It issues license keys, validates them, tracks machine activations and enforces policies such as expiry, seats and feature entitlements. Desktop apps, on-premise software, plugins and SaaS add-ons call it to check whether a customer's license is valid. Keygen CE is the free self-hosted edition.

## About Hosting Keygen

This template runs Keygen CE `keygen/api:v1.7.2` as a web service and a Sidekiq worker, with Railway Postgres and Redis. On the first deploy, a pre-deploy step runs Keygen's setup, which creates the account and an admin user. Later deploys only run migrations. The pre-deploy step also waits for the database. Setup output is filtered so that secrets stay out of the logs. The admin email defaults to `admin@example.com`, and the password is generated. CE is API-only, without a dashboard. Keygen is published under the Fair Core License, which is source-available rather than open source.

## Common Use Cases

- License keys and activation limits for desktop or on-premise software
- Feature entitlements and trials checked by your app at runtime
- Offline license files and machine fingerprinting for air-gapped installs

## Dependencies for Keygen Hosting

- `keygen/api:v1.7.2` (Keygen CE), as `keygen` and `keygen-worker`
- Railway Postgres and Railway Redis

### Deployment Dependencies

- [Keygen self-hosting](https://keygen.sh/docs/self-hosting/)
- [Keygen API reference](https://keygen.sh/docs/api/)
- [Keygen license (FCL)](https://keygen.sh/license/)

### Implementation Details

| Service | Source | Networking | Storage |
| --- | --- | --- | --- |
| keygen | `keygen/api:v1.7.2` (web) | public HTTPS | Postgres + Redis |
| keygen-worker | `keygen/api:v1.7.2` (Sidekiq) | private | Postgres + Redis |
| Postgres, Redis | Railway databases | private | volumes |

| Variable | Purpose |
| --- | --- |
| `KEYGEN_ACCOUNT_ID` | Generated account ID; part of every API path |
| `KEYGEN_ADMIN_EMAIL`, `KEYGEN_ADMIN_PASSWORD` | First admin, created by setup |
| `KEYGEN_HOST` | Public domain; change it if you add a custom domain |
| `SECRET_KEY_BASE`, `ENCRYPTION_*` | Generated keys; keep them, they protect data at rest |

Validate a key (no auth needed):

```bash
curl -XPOST "$KEYGEN_URL/v1/accounts/$KEYGEN_ACCOUNT_ID/licenses/actions/validate-key" \
  -H 'Content-Type: application/vnd.api+json' -d '{"meta":{"key":""}}'
```

Change `KEYGEN_ADMIN_EMAIL` before the first deploy if you want your own address; setup only runs once. Under the FCL, you may self-host Keygen for your own products, but you may not offer it as a competing licensing service.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by Keygen LLC.

## Why Deploy Keygen 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 Keygen 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

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/keygen-1
