# READONLY: Write rejected on a read only replica

> The connection points at a replica, and Redis refuses writes there: only the primary accepts commands that modify data.

Source: https://sqlly.app/errors/redis/readonly
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Error prefix: `READONLY`
- Category: Cluster and replication

Error message:

```text
READONLY You can't write against a read only replica.
```

## What it means

READONLY means the write landed on a replica. A Redis replica serves reads (by default, possibly stale data), but every write must go to the primary so it can be replicated in order. With replica-read-only at its default of yes, any write command on a replica gets this error instead of executing.

It usually means the client is pointed at the wrong host: a connection string still naming yesterday's primary, a DNS record that moved after a failover, or a proxy that hands out replicas to writers. It also bites after a manual promotion when the old primary was never demoted and clients keep writing to it.

## Common causes

- The connection string or DNS name points at a replica instead of the primary.
- A failover or promotion finished and clients still hold the old primary's address, which is now a replica.
- A proxy or service discovery layer includes replicas in the pool it hands to writers.

## How to fix it

1. Check what the node you are connected to believes it is:

   ```sql
   redis-cli -h node-2 INFO replication | grep 'role:'
   # role:slave means writes fail here
   ```
2. Ask any replica where the primary is now:

   ```sql
   redis-cli -h node-2 INFO replication | grep master_host
   redis-cli -h node-2 ROLE
   ```
3. Point writers at the primary. After a promotion, demote the old primary so it follows the new one:

   ```sql
   redis-cli -h old-primary REPLICAOF new-primary 6379
   ```

## Reproduce it safely

```sql
redis-server --port 7302 --replicaof 127.0.0.1 6399 --save '' &
redis-cli -p 7302 SET foo bar
# (error) READONLY You can't write against a read only replica.
redis-cli -p 7302 GET foo
# (nil) - reads still work; stale data is served by default
```

## How SQLly helps

SQLly shows the full READONLY line instead of hiding it behind a driver wrapper, and ROLE and INFO replication run in the same editor, so you can confirm the node's role and find the current primary without another tool.

## Questions

### Can I make a replica writable?

replica-read-only no exists, but such writes are not replicated and vanish on the next synchronization. It is meant for special setups, not as a workaround.

### Why did the same write work yesterday and fail today?

The node changed role. Failover tools swap primaries and replicas; your client kept the old address, which is now a replica.

## Related errors

- [`MASTERDOWN`](https://sqlly.app/errors/redis/masterdown): Stale data is not allowed to be served
- [`SQLITE_READONLY`](https://sqlly.app/errors/sqlite/sqlite-readonly): SQLite: attempt to write a readonly database
- [`25006`](https://sqlly.app/errors/postgresql/25006): PostgreSQL: read-only SQL transaction

The code and message text are from the [Redis documentation and source code](https://redis.io/docs/latest/).
