# Error: Replication sync failed, replica id mismatch, expected <replica_id> but got <replica_id>

- **ID:** `redis/sync-replica-id-mismatch`
- **Domain:** redis
- **Category:** runtime_error
- **Error Code:** `ERR`
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

During partial resynchronization, the replica's cached master replication ID does not match the current master's replication ID, often due to master restart or failover.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 6.2.0 | active | — | — |
| 7.0.0 | active | — | — |
| 7.2.0 | active | — | — |
| 7.4.0 | active | — | — |

## Workarounds

1. **On the replica, run `SLAVEOF NO ONE` then `SLAVEOF <master_ip> <master_port>` to force a full resynchronization.** (95% success)
   ```
   On the replica, run `SLAVEOF NO ONE` then `SLAVEOF <master_ip> <master_port>` to force a full resynchronization.
   ```
2. **If using Redis Sentinel, trigger a manual failover: `redis-cli -p 26379 SENTINEL failover <mymaster>` to elect a new master and force replicas to sync with a fresh replication ID.** (85% success)
   ```
   If using Redis Sentinel, trigger a manual failover: `redis-cli -p 26379 SENTINEL failover <mymaster>` to elect a new master and force replicas to sync with a fresh replication ID.
   ```
3. **In a cluster environment, use `CLUSTER REPLICATE <node-id>` on the replica after ensuring the master is healthy and has a consistent replication ID.** (90% success)
   ```
   In a cluster environment, use `CLUSTER REPLICATE <node-id>` on the replica after ensuring the master is healthy and has a consistent replication ID.
   ```

## Dead Ends

- **** — Restarting the replica without clearing its replication backlog or ID cache does not fix the underlying mismatch; the replica will retry with the same stale ID. (75% fail)
- **** — Manually setting repl-id using CONFIG SET on the master is risky and may break replication for other replicas; it does not address the root cause of ID divergence. (90% fail)
- **** — Increasing repl-backlog-size on the master alone does not resolve a mismatched replication ID; the replica must perform a full sync to reset the ID. (80% fail)
