---
title: "Redis READONLY errors after a failover: which node is the client on? | Proofline"
description: "After a failover, the READONLY error means the client sent a write to a node that is now a replica."
url: https://proofline.sh/learn/redis-readonly-replica-after-failover/
---

[Learning center](/learn/)

# Redis READONLY errors after a failover: which node is the client on?

After a failover, the READONLY error means the client sent a write to a node that is now a replica. Ask that node for its ROLE, then compare the address the client is connected to with the address the primary endpoint resolves to now. If they differ, the client is holding an old connection, caching an old address or configured with a node endpoint, and the cache itself has already recovered.

Broken dependencies The Proofline team November 23, 2026 5 min read

## The symptom

Writes fail with `READONLY You can't write against a read only replica.` while reads from the same client succeed. Redis rejects every write command on a replica because `replica-read-only` is on by default. [Redis source, server.c](https://github.com/redis/redis/blob/unstable/src/server.c) · [Read-only replica](https://redis.io/docs/latest/operate/oss_and_stack/management/replication/)

The errors begin at a failover: a primary was replaced or a replica promoted, and the old primary came back as a replica. The new primary accepts writes from clients that found it. Clients that did not are still talking to the node that was demoted.

This guide is one of a set on [runtime dependency failures](/learn/runtime-dependency-failures/).

## Three ways a client stays on the old primary

-   Open connections survive. A DNS change affects only new lookups. A pool that opened its connections to the old primary keeps using them after that node becomes a replica, and nothing closes them unless the client reacts to the error or the node drops the connection.
-   The client cached the old address. The runtime, the client library or a local resolver keeps the address it resolved before the failover and reconnects to it. [Client caches old address](/learn/dns-client-caches-old-address-after-failover/)
-   The configuration names a node instead of the primary. On ElastiCache with cluster mode disabled, the primary endpoint is a DNS name that always resolves to the primary node, and it follows a promotion. Node endpoints resolve to specific nodes. An application configured with the endpoint of node 001 keeps writing to node 001 whatever its role. [ElastiCache endpoints](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Endpoints.html)

ElastiCache propagates the promoted replica's DNS name to the primary endpoint during a Multi-AZ failover, so applications that write to the primary endpoint need no change; the reader endpoint is updated to point at replicas. [Multi-AZ failover](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/AutoFailover.html)

## Ask the nodes and the resolver

`ROLE` returns `master` or `slave` as its first element; a replica also returns its primary's address and its replication state. `INFO replication` adds `role`, `master_host` and `master_link_status`. Both are read-only. [ROLE](https://redis.io/docs/latest/commands/role/) · [INFO replication fields](https://redis.io/docs/latest/commands/info/)

```
redis-cli -h NODE_ADDRESS -p 6379 ROLE
redis-cli -h NODE_ADDRESS -p 6379 INFO replication
```

List the replication group's nodes, their current roles and the primary endpoint. `CurrentRole` is reported per member for cluster mode disabled. [describe-replication-groups](https://docs.aws.amazon.com/cli/latest/reference/elasticache/describe-replication-groups.html)

```
aws elasticache describe-replication-groups \
  --profile PROFILE --region REGION --replication-group-id REPLICATION_GROUP_ID \
  --query 'ReplicationGroups[0].NodeGroups[].{primary:PrimaryEndpoint.Address,members:NodeGroupMembers[].{node:CacheClusterId,role:CurrentRole,address:ReadEndpoint.Address}}' \
  --output json --no-cli-pager

aws elasticache describe-events \
  --profile PROFILE --region REGION \
  --source-type replication-group --source-identifier REPLICATION_GROUP_ID \
  --duration 360 --no-cli-pager
```

`describe-events` returns the group's events for the given number of minutes, including the failover and its time. [describe-events](https://docs.aws.amazon.com/cli/latest/reference/elasticache/describe-events.html)

Then compare, from inside the client's container or host, what the endpoint resolves to and where the open connections go:

```
getent hosts PRIMARY_ENDPOINT
dig +short PRIMARY_ENDPOINT
ss -tn state established '( dport = :6379 )'
```

`getent` resolves through the same system resolver the application uses, while `dig` asks the DNS server directly, so a difference between them points at a local cache. Neither shows a cache inside the application runtime; the remote addresses in `ss` show where the process is actually connected. [getent(1)](https://man7.org/linux/man-pages/man1/getent.1.html) · [ss(8)](https://man7.org/linux/man-pages/man8/ss.8.html)

From the server side, `CLIENT LIST` on the demoted node shows the `addr` of every client still connected to it. It is O(N) in connections, so run it once. [CLIENT LIST](https://redis.io/docs/latest/commands/client-list/)

## Decision table

| Configured host | Endpoint resolves to | Open connections go to | Points to |
| --- | --- | --- | --- |
| Node endpoint | that node | that node, now a replica | Configuration names a node |
| Primary endpoint | new primary | old primary | Pool kept connections across the failover |
| Primary endpoint | old primary, in `getent` only | old primary | Local or runtime DNS cache |
| Primary endpoint | new primary | new primary | Errors came from before reconnect; check timestamps |

## An illustrative failover with two outcomes

This example is illustrative. The `payments` service writes idempotency keys to an ElastiCache replication group `payments-cache` in account `111122223333`. At 03:14 UTC a failover promotes `payments-cache-002` (`10.0.8.42`) and `payments-cache-001` (`10.0.8.17`) returns as a replica. From 03:15, some `payments` tasks log READONLY errors on every write.

In the first outcome, the failing tasks' configuration sets `REDIS_HOST=payments-cache-001.cache.example.internal`, standing in for the node endpoint someone copied from the console during setup. `ROLE` on that host returns `slave` with master `10.0.8.42`. Every new connection from those tasks reaches the replica. The fix is the primary endpoint in configuration, and the cache needs nothing.

In the second outcome, every task uses the primary endpoint, and both `getent` and `dig` return `10.0.8.42` inside a failing task. `ss` in the same task shows eight established connections to `10.0.8.17`, opened at 01:02. The client library keeps healthy-looking connections in its pool and does not close them on READONLY. Tasks started after 03:14 write normally. Recycling the failing tasks clears the errors. The lasting fix is a client that drops a connection when it returns READONLY and opens a new one through the primary endpoint.

## Limits

The `CurrentRole` field and the primary endpoint apply to cluster mode disabled. With cluster mode enabled, clients connect through the configuration endpoint and discover each shard's primary themselves. [ElastiCache endpoints](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Endpoints.html)

A single-node cluster has no primary endpoint and no replica to promote. When its node is replaced, the new primary starts empty unless restored from a snapshot. That shows up as missing data, with no READONLY error. [Multi-AZ failover](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/AutoFailover.html)

Redis replicates asynchronously by default, so writes the old primary accepted but had not yet replicated can be missing on the new primary, and that loss raises no READONLY error. [Replication](https://redis.io/docs/latest/operate/oss_and_stack/management/replication/) If the incident also involves missing keys or connection refusals, those are separate questions. [Max clients or timeouts](/learn/redis-max-clients-or-timeouts/) · [Connection refused or timeout](/learn/connection-refused-vs-timeout/)

## Questions

### Why do only some instances get READONLY after a Redis failover?

Instances that opened connections or resolved the address after the promotion reach the new primary. Instances still holding connections opened before it, or caching the old address, keep writing to the demoted node. Compare the remote address of each instance's open connections.

### Does the ElastiCache primary endpoint change during failover?

The name stays the same; ElastiCache points it at the promoted node. Applications that use it get the new primary on their next lookup, but connections already open stay where they were.

### What does ROLE return on a replica?

The string `slave` for backward compatibility, followed by the primary's address and port, the replication state and the replication offset received so far.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Clients still use the old address after a database failover](/learn/dns-client-caches-old-address-after-failover/)
    
    Network outages The Proofline team November 23, 2026 5 min read
    
-   ### [Redis max clients reached, or timeouts from a slow server?](/learn/redis-max-clients-or-timeouts/)
    
    Capacity overruns The Proofline team November 23, 2026 6 min read
