---
title: "Deploy unkey"
description: "Unkey - The Developer Platform for Modern APIs"
category: "Other"
url: https://railway.com/deploy/unkey
---

# Deploy unkey

Unkey - The Developer Platform for Modern APIs

**[Deploy unkey on Railway](https://railway.com/template/unkey)**

- **Creator:** My Workspace
- **Category:** Other
- **Total deploys:** 11

## Template content

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

- **Image:** redis:8.2.1
- **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"`

### MySQL https://devicons.railway.app/i/mysql.svg

- **Image:** mysql:9.4
- **Start command:** `docker-entrypoint.sh mysqld --innodb-use-native-aio=0 --disable-log-bin --performance_schema=0 --innodb-buffer-pool-size=1G`

### unkeyed/unkey:v2.0.49 https://www.unkey.com/unkey.png

- **Image:** ghcr.io/unkeyed/unkey:v2.0.49
- **Start command:** `unkey run api`
- **Public domain:** Yes

## Documentation

# Deploy and Host Unkey on Railway

Unkey is an open-source API management platform that allows developers to secure their services with **low-latency API key authentication**. It provides out-of-the-box features such as **rate limiting**, **usage tracking**, and **temporary keys**, enabling you to build and scale your API infrastructure without creating a custom authentication layer from scratch.

---

## About Hosting Unkey

Hosting Unkey involves deploying a **high-performance Go-based backend** alongside supporting data services.

Unkey is designed for speed (targeting **&lt;40ms key verification**), and its architecture relies on:

- **MySQL** for persistent data (API configs, key metadata, encrypted hashes)
- **Redis** for real-time state management and rate-limiting counters

Earlier versions depended on third-party providers like PlanetScale. The modern Unkey stack is now **fully self-hostable**, meaning you can run the **API and Dashboard** entirely using open-source databases.

**Railway** simplifies this process by:

- Provisioning databases automatically
- Injecting environment variables securely
- Connecting services via a private internal network

---

## Common Use Cases

### SaaS API Authentication
Issue and manage unique API keys for customers with built-in revocation and rotation.

### AI / LLM Usage Guardrails
Apply per-user rate limits and usage caps to prevent runaway AI costs.

### Microservices Gateway
Secure internal service-to-service communication using short-lived or metadata-tagged keys.

---

## Dependencies for Unkey Hosting

### Required Services

- **MySQL**
  - Stores API configurations
  - Key metadata
  - Encrypted key hashes

- **Redis**
  - High-speed rate limiting
  - Temporary counters
  - Session and state data

---

### Deployment Dependencies

- Unkey GitHub Repository
- Official Unkey Documentation
- Railway MySQL Documentation

---

## Railway Implementation Details

### MySQL Connection String

When configuring Unkey on Railway, ensure the database URL uses the **Go MySQL driver format**:

```
${{MySQL.MYSQLUSER}}:${{MySQL.MYSQLPASSWORD}}@tcp(${{MySQL.MYSQLHOST}}:${{MySQL.MYSQLPORT}})/${{MySQL.MYSQLDATABASE}}?parseTime=true
```

Set this value to:

```
UNKEY_DATABASE_PRIMARY
```

---

### Redis Connection String

Use the following format for Redis:

```
redis://default:${{Redis.REDISPASSWORD}}@${{Redis.REDISHOST}}:${{Redis.REDISPORT}}
```

Set this value to:

```
UNKEY_REDIS_URL
```

---

### Root Key Generation

Generate a secure root key directly in Railway using its random generator:

```
UNKEY_ROOT_KEY=${{random.hex(32)}}
```

This key is required to bootstrap and administer Unkey securely.

---

## Why Deploy Unkey on Railway?

Railway is a **single platform** for deploying full infrastructure stacks.

Benefits include:

- Zero-config database provisioning
- Secure internal networking
- Automatic environment variable injection
- Vertical and horizontal scaling
- One-click deployments for services and databases

By deploying Unkey on Railway, you can support a **production-grade API authentication layer** with minimal operational overhead.

Host your **servers, databases, APIs, and AI workloads**—all in one place.

---

## Summary

- ✅ Fully self-hosted Unkey stack
- ✅ MySQL + Redis architecture
- ✅ Railway-managed infrastructure
- ✅ Secure, scalable, low-latency API auth

Perfect for SaaS platforms, AI products, and internal microservices.



## 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/unkey
