# Redis: READONLY You can't write against a read only replica

**Code:** `READONLY You can't write against a read only replica` · **Category:** Redis · **Seen on:** Redis

The client is connected to a replica (or a failed-over node) and tried to write.

## Meaning

After a failover the old primary becomes a replica, clients with stale connections or a hard-coded host keep writing to it. Use Sentinel/cluster-aware clients or the managed primary endpoint.

## Common causes

- Connected to a replica host/port
- Failover happened, client still on old primary
- Read-only endpoint used for writes (managed Redis)

## Quick fix

1. Use the primary/write endpoint
2. Use Sentinel or cluster-aware client configuration
3. Reconnect clients after failover

## Detailed fix by platform

### Shell

1. `redis-cli -h $HOST INFO replication | grep role`

## How to diagnose

1. **Role** — master or slave/replica?
2. **Endpoint** — Primary or reader?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/redis/readonly-cant-write-against-replica)
