---
title: "Deploy Redis Sentinel"
description: "Sentinel-aware clients on a 3-node Redis failover cluster"
category: "Storage"
url: https://railway.com/deploy/deploy-redis-sentinel-with-failover
---

# Deploy Redis Sentinel

Sentinel-aware clients on a 3-node Redis failover cluster

**[Deploy Redis Sentinel on Railway](https://railway.com/template/deploy-redis-sentinel-with-failover)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/deploy-redis-sentinel-with-failover/manifest.json

- **Creator:** onepush
- **Category:** Storage

## Template content

### redis-1

- **Image:** ghcr.io/onepush-dev/redis-ha-node:8.10.3@sha256:672f6310650c226fdae0acdeff10f4e82dfce7d38096e35a8ec61069588f271e

### redis-2

- **Image:** ghcr.io/onepush-dev/redis-ha-node:8.10.3@sha256:672f6310650c226fdae0acdeff10f4e82dfce7d38096e35a8ec61069588f271e

### redis-3

- **Image:** ghcr.io/onepush-dev/redis-ha-node:8.10.3@sha256:672f6310650c226fdae0acdeff10f4e82dfce7d38096e35a8ec61069588f271e

### Redis

- **Image:** ghcr.io/onepush-dev/redis-ha-router:8.10.3@sha256:a86aacda65af654a1109bf9b154e8cb124ec6e8f273aedb62088103d4a36ff7f
- **Health check:** /health

## Documentation

# Deploy and Host self hosted Redis Sentinel (3-Node Redis Cluster with Sentinel Failover) on Railway

This template runs three Redis 8.10 nodes, each with a colocated Sentinel, plus an HAProxy router that always points writes at the primary.

## About Hosting Redis Sentinel open-source software on Railway (self hosted Redis Sentinel failover template)

This template runs three Redis 8.10.3 nodes, each with a colocated Sentinel, plus an HAProxy router that gives your apps one stable address.

## Why Deploy Redis Sentinel, the Redis Cloud alternative on Railway (Railway Free Trial)

Redis Cloud is easy but costs more per plan and limits your control over node layout and Sentinel settings.

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 Redis Sentinel 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.

### Railway vs Other Hosting Providers and VPS for Redis Sentinel self hosting

Here is how Railway compares with the usual alternatives for three Redis nodes with colocated Sentinels.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | Three nodes and the router from one template, with the private network already wired. | Three Droplets you configure yourself, with your own firewall and Sentinel config. |
| AWS | Sentinel quorum, AOF, and the router set up without touching VPC or security groups. | Full networking control, but you assemble the Sentinel topology yourself. |
| Hetzner | Managed deploys with the same failover behaviour and no server patching. | Cheap hardware, offset by hands-on setup and upkeep. |

Choose Railway for a fast, working failover setup, and a VPS when you need full hardware control.

## Common Use Cases for hosted Redis Sentinel

- **Job queues that must survive a node loss:** A BullMQ worker keeps pulling jobs when the primary dies, because Sentinel promotes the most up-to-date replica within a few seconds and the client reconnects to the new primary without a restart.
- **Session stores with automatic failover:** Logins live in Redis, so a failover should not log everyone out. Point the session store at Sentinel mode and the app follows the new primary on its own.
- **Apps that follow primary changes without a proxy:** Sentinel-aware clients ask the Sentinels for the current primary, so you skip the router hop and still track role changes.
- **Read scaling on replicas via the client:** Use the Sentinel-aware client's replica lookup to send cache reads to the two replicas, and keep writes pinned to the primary.
- **Testing failover behaviour before production:** Run SENTINEL failover mymaster against staging and watch whether your app recovers cleanly. Better to find the reconnect bug on a Tuesday afternoon than during a real incident.

## Dependencies for Redis Sentinel Docker hosted on Railway

This template runs three Redis 8.10 nodes, each with a colocated Sentinel, behind an HAProxy router.

### Deployment Dependencies for Managed Redis Sentinel Service (Database)

The template needs no inputs. Each node mounts a persistent volume at /data, and AOF is on by default through REDIS_APPENDONLY set to yes.

### Implementation Details for Redis Sentinel (Using Redis HA official docker image)

The nodes run ghcr.io/onepush-dev/redis-ha-node:8.10.3, built on redis:8.10.3-trixie with the JSON, Search, TimeSeries and Bloom modules loaded.

## How does Redis Sentinel compare against other ways to run highly available Redis

### Redis Sentinel vs Redis Cluster (Sharded Redis Alternative)

- **Scale model:** Sentinel keeps one primary with the whole dataset, plus replicas that can take over. Cluster shards keys across several masters, so it wins when one node cannot hold your data or write rate.
- **Client support:** Sentinel clients ask the Sentinels for the primary, which ioredis, redis-py and Lettuce all support. Cluster needs a cluster-aware client.
- **Multi-key operations:** On Sentinel, commands across any keys run on one node. On Cluster, keys must share a hash slot.

### Redis HA vs Redis Cloud (Managed Redis Alternative)

- **Ownership:** This template runs in your Railway project, so the data and config stay with you. Redis Cloud is run by Redis Inc.
- **Operations:** You handle upgrades, backups and capacity planning here. Redis Cloud takes on more of that work.
- **Where Redis Cloud wins:** Vendor support, global replication and a long track record at scale.

### Sentinel clients vs the HAProxy router (Connection Method Alternative)

- **Simplicity:** The router's REDIS_URL always points at the primary, so an app without Sentinel support still gets failover. Sentinel mode needs more client code.
- **Failover speed:** A Sentinel-aware client can reconnect as soon as the Sentinels name the new primary. The router picks up the change on its next role check.
- **Private network only:** Sentinels announce private hostnames, so Sentinel mode works only inside the Railway project.

### Redis Sentinel vs Valkey Sentinel (Open Source Fork Alternative)

- **Protocol:** Both use the same Sentinel commands and master-name model, so client code usually works against either.
- **Redis version:** This template runs Redis 8.10 with the bundled modules. Valkey runs its own fork, so check module and command support before switching.
- **License:** Redis moved to a dual license, while Valkey stayed under an open license. Pick the project your organization is comfortable depending on.

## How to use Redis Sentinel (the OSS in-memory data store)?

1. Deploy the template and wait until redis-1, redis-2, redis-3 and the router are healthy. First start takes about five minutes.
2. In your app, reference REDIS_SENTINEL_HOSTS, REDIS_MASTER_NAME and REDIS_PASSWORD from the router.
3. Configure your client with sentinels, name, password, sentinelPassword and family 0.
4. Run one write and one read to confirm the connection.
5. Check the primary with `redis-cli -p 26379 -a "$REDIS_PASSWORD" SENTINEL get-master-addr-by-name mymaster`.
6. Trigger `SENTINEL failover mymaster` and confirm the app keeps writing.

```javascript
// ioredis
const redis = new Redis({
  sentinels: parseSentinels(process.env.REDIS_SENTINEL_HOSTS),
  name: process.env.REDIS_MASTER_NAME,
  password: process.env.REDIS_PASSWORD,
  sentinelPassword: process.env.REDIS_PASSWORD,
  family: 0,
});
```

```python
# redis-py
sentinel = Sentinel(sentinels, sentinel_kwargs={"password": pw}, password=pw)
master = sentinel.master_for(os.environ["REDIS_MASTER_NAME"])
```

## How to self host Redis Sentinel on other VPS Services (Redis HA self hosting guide)

Self hosting means you run the three nodes and the router yourself, and you handle the networking and failover checks that Railway normally covers.

### Clone the Repository

Grab the upstream project and move into it.

```bash
git clone https://github.com/onepush-dev/redis-ha.git
cd redis-ha
```

### Install Dependencies

Each node and the router need Docker. Open ports 6379, 6380, 26379 and 8080 only between your hosts, never to the public internet.

```bash
sudo apt-get update && sudo apt-get install -y docker.io
```

### Configure Environment Variables

Use the same password on every node and the router, and list all three node addresses in the same order everywhere. Sentinels need the password too.

```bash
REDIS_PASSWORD=one-long-random-string-shared-by-all-nodes
REDIS_MASTER_NAME=mymaster
SENTINEL_QUORUM=2
SENTINEL_DOWN_AFTER_MS=5000
```

### Start the Redis Sentinel Application

Start redis-1 first so it bootstraps as primary, then start redis-2, redis-3 and the router.

Railway handles the private networking, healthchecks and failover orchestration for you.

## Official Pricing of Redis Sentinel (Redis HA pricing)

Redis Sentinel is open source and free to use, so there is no license fee. Railway's $5 trial credit is enough to deploy the stack and run a failover test before you commit.

## Redis Sentinel cloud vs self hosted comparison (Pricing, features, costs, and more)

Running Redis Sentinel yourself means you own the failover, the passwords, and the bill.

### Monthly cost of self hosting Redis Sentinel on Railway

On Railway, expect roughly $20-50 a month for three Redis nodes plus the router at light use. The bill climbs as memory grows, since each node holds the full dataset.

### System Requirements for Hosting Redis Sentinel on a VPS

Each node runs Redis 8.10.3 with a colocated Sentinel, so a VPS needs three machines or containers with enough RAM for your dataset plus headroom.

## Frequently Asked Questions (FAQs)

### Should my app use the router REDIS_URL or Sentinel mode?

Use REDIS_URL if you want the simplest setup, because the router always points at the current primary and your client needs no changes.

### Why does Sentinel mode fail when I run it from my laptop?

Sentinels announce Railway private hostnames, so they only resolve inside the same project's private network.

### Does Sentinel need a password?

Yes.

### How long does a failover take?

In the fresh test, a replica was promoted about 3 seconds after the primary was redeployed, and writes resumed about 4.4 seconds in. Your app should see a short pause, not a restart.

### What happens if two nodes go down?

With only one Sentinel left, quorum 2 can't be met, so no new primary gets elected until a second node returns. Writes stop in the meantime, and a restarted node rejoins as a replica.

### Do I need family 0 for ioredis and BullMQ?

Yes. Railway private networking is IPv6, so set family: 0 in your ioredis connection options, and BullMQ will pass the same options through.


## Similar templates

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.

Open this page in a browser: https://railway.com/deploy/deploy-redis-sentinel-with-failover
