---
title: "Deploy Valkey"
description: "Open-source Redis-compatible in-memory database with auth and persistence."
category: "Storage"
url: https://railway.com/deploy/valkey-2
---

# Deploy Valkey

Open-source Redis-compatible in-memory database with auth and persistence.

**[Deploy Valkey on Railway](https://railway.com/template/valkey-2)**

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

- **Creator:** Sendly
- **Category:** Storage
- **Total deploys:** 1

## Template content

### Valkey https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/valkey.svg

- **Image:** valkey/valkey
- **Start command:** `/bin/sh -c "exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD}"`

## Documentation

# Deploy and Host Valkey on Railway

Valkey is a high-performance, open-source in-memory data store, born as a community-driven fork of Redis and backed by the Linux Foundation. It's fully compatible with the Redis protocol and clients, making it a drop-in replacement for caching, session storage, queues, and real-time data workloads, with sub-millisecond latency.

## About Hosting Valkey

Hosting Valkey means running a persistent, password-protected in-memory database that your applications can reach quickly and securely. This template deploys the official `valkey/valkey` Docker image with authentication enabled out of the box: a random 32-character password is generated automatically on deploy, and the server starts with the port and credentials already wired up. Your other Railway services connect over the private network using the provided `VALKEY_URL`, while an optional TCP proxy exposes a public URL for external access. Attach a volume at `/data` to persist your data across redeployments. No manual configuration, no Dockerfiles, and no server maintenance required.

## Common Use Cases

- **Caching layer:** Speed up APIs and web apps by caching database queries, rendered pages, and expensive computations.
- **Session and rate-limit storage:** Store user sessions, tokens, and request counters with built-in key expiration.
- **Job queues and background workers:** Power queue libraries like BullMQ, Celery, or Sidekiq with fast, reliable queues.
- **Real-time features:** Build leaderboards, pub/sub messaging, live notifications, and counters.

## Dependencies for Valkey Hosting

- Valkey official Docker image (`valkey/valkey`)
- A Railway Volume mounted at `/data` (recommended for data persistence)

### Implementation Details

The template pre-configures these environment variables:

| Variable | Description |
|---|---|
| `VALKEY_DATABASE_URL` | Private connection URL for services inside your Railway project |
| `VALKEY_PUBLIC_DATABASE_URL` | Public connection URL via TCP proxy |
| `VALKEY_PASSWORD` | Auto-generated 32-character password |
| `VALKEY_PORT` | Server port (default `6379`) |

The service starts with the following command, which passes the port and password to the official image's entrypoint:

```bash
/bin/sh -c "exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD}"
```

Connect from your app using any Redis-compatible client. Example with Node.js:

```javascript
import { createClient } from "redis";

const client = createClient({ url: process.env.VALKEY_URL });
await client.connect();

await client.set("hello", "Valkey on Railway");
console.log(await client.get("hello"));
```

Test the connection from the CLI:

```bash
valkey-cli -u "$VALKEY_PUBLIC_URL" ping
# PONG
```

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

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/valkey-2
