skip to content

After a Redis failover, clients get `WRONGPASS` although `ACL SETUSER` succeeded on the old primary; why, and how should users reach every node?

level: seniorimportance: should knowfreq 40%

answer

  1. users live in one process's memory
  2. not in the replication stream
  3. restart loses unsaved users
  4. one file per node, two storage modes
  5. what the file must say about default

basics

~20 s

ACL SETUSER changes only the server that received it: users are not replicated, so the promoted replica never had them. Define users in an aclfile or redis.conf deployed to every node, and include the replication and Sentinel users.

solid answer

~40 s

`ACL SETUSER` edits one server's memory. It is not a write, so it never enters the replication stream, and the cluster bus does not carry users either. A promoted replica therefore answers `WRONGPASS` for a user it never received, and a restart loses any unsaved change even on the node that had it. So I treat users as configuration: one `aclfile` deployed to every node and applied with `ACL LOAD`, or `user` lines in `redis.conf` saved with `CONFIG REWRITE`. Redis refuses to start with both. The file must define `default`, because a file without it brings that user back as `on nopass ~* &* +@all`, ignoring `requirepass`. Every node also needs the replication and Sentinel users, since any node can become primary.

code

conf · 10 lines
conf
# redis.conf, on every node
aclfile /etc/redis/users.acl
masteruser replica-user
masterauth REPLICA_SECRET

# /etc/redis/users.acl, the same file on every node
user default off
user ops on #ADMIN_SHA256 ~* &* +@all
user replica-user on #REPLICA_SHA256 +psync +replconf +ping
user checkout on #CHECKOUT_SHA256 +@read +@write -@dangerous +ping ~checkout:*

go deeper

for a junior

Recall that ACL users belong to one server, and that a change made with ACL SETUSER disappears on restart unless it has been saved to a file.

for a middle

Explain the two storage modes, why they cannot be combined, and which command persists each: CONFIG REWRITE for redis.conf users, ACL SAVE for an aclfile, ACL LOAD to reread it.

for a senior

Diagnose WRONGPASS after failover from the fact that users are per node, and name the traps: a file missing default, a load that drops hand-made users, and replication users absent on replicas.

for a principal

Decide how the rule set is delivered and how drift is detected, and make adding a node or user a deployment step rather than something an operator remembers on the night.

## Why the user was missing ACL users live in the memory of one Redis process. `ACL SETUSER` changes that memory and replies `OK`, and nothing else happens: - **Not replicated.** The command carries no write flag and changes no data, so it is not fed to replicas, and no code path sends users to them. - **Not gossiped.** Cluster bus messages carry no users, so Redis Cluster nodes do not share them. - **Not in the snapshot.** Users are not saved in RDB files, so a full resync brings none over and a restart loses any unsaved change. After a failover, a client logging in as a user only the old primary knew gets `WRONGPASS invalid username-password pair or user is disabled.` That reply covers a missing user and a wrong password alike. If the user exists with older rules, the symptom is `NOPERM` instead. The command metadata can mislead here. `ACL SETUSER` carries the tip `request_policy:all_nodes`, which tells a cluster-aware client that it should send the command to every node. It is advice to the client. The server does not fan it out, and a plain `redis-cli` connection reaches one node. ## Two ways to store users | | `user` lines in `redis.conf` | External `aclfile` | |---|---|---| | Saved with | `CONFIG REWRITE` | `ACL SAVE` | | Reloaded with | A restart | `ACL LOAD` | | Best for | A few users | Many users, as the docs recommend | | `ACL LOAD` and `ACL SAVE` | Reply with an error | Work | The two are **mutually incompatible**. If `redis.conf` has `user` lines and also sets `aclfile`, the server logs a warning and exits at startup. `aclfile` cannot be changed with `CONFIG SET`, so moving between them needs a restart. The traps worth knowing with `aclfile`: - **`default` must be in the file.** If no line defines it, `ACL LOAD` and startup recreate it as `on nopass ~* &* +@all`, and `requirepass` is ignored. A tidy file listing only service users opens the server. - **The file must exist.** Redis aborts startup when it cannot open it. - **Loading is all or nothing.** One bad line makes `ACL LOAD` return an error and keep the previous rules. - **Loading replaces the whole set.** Users missing from the file are dropped and their connections closed, and a hand-made `ACL SETUSER` on that node goes with them. - **`CONFIG REWRITE` does not save users** in this mode, so `ACL SAVE` is a separate step. - **`ACL SAVE` overwrites the file.** Since Redis 8.8, `ACL LOAD` accepts `#` comment lines but strips them, so saving loses comments. ## Getting users to every node Treat the rules as configuration that is delivered, not as commands that are typed: 1. Keep one `aclfile` as the source and deploy it to every node, replicas included. 2. Run `ACL LOAD` on each node. In Redis Cluster that means every primary and replica, so include nodes added later in the same process. 3. Add a user everywhere before a client starts using it, and remove it everywhere only after the client has stopped. 4. Compare `ACL LIST` across nodes to detect drift. Passwords appear as hashes, so comparing them needs no cleartext. Store `#<sha256>` hashes rather than `>` cleartext in the file, since it is on disk on every node. Whichever mode you choose, a change made only by `ACL SETUSER` is a change on one server, until it reaches the file. ## The users Redis itself needs Redis's own links use ACL users too, and they need the same care: - **Replication.** A replica logs in with `masteruser` and `masterauth`. On the primary, it needs `+psync +replconf +ping`. Define that user on every node, because a failover swaps the roles. Writes arriving from the primary are not checked against the replica's ACLs. - **Sentinel.** With `default` off, each monitored node needs a user with Sentinel's command list, configured through `sentinel auth-user` and `sentinel auth-pass`. A Sentinel process has ACL users of its own as well, and its docs say to apply the same configuration across all Sentinels. Skip these and turning `default` off breaks replication or failover rather than client traffic, which makes the cause harder to see.

  • `ACL LOAD` on one node reports an error for one line. What state are its users in now?
    The previous rules are still active. Redis builds the new user set from the whole file first, and if any line fails it discards that set and reports the errors, with a warning that no change was made. The risk is across nodes: if the file already loaded elsewhere, your nodes now disagree.
  • Why can a primary's `requirepass` stop mattering after you add an `aclfile`?
    `redis.conf` says `requirepass` is not compatible with `aclfile` and `ACL LOAD`, which cause it to be ignored. The `default` user comes wholly from the file, and if the file has no line for it, Redis creates it as `on nopass ~* &* +@all`. Always write the `default` line yourself.
  • What does a client see while a new user has reached only some nodes?
    Whichever node it connects to decides. Nodes that have the user accept it, and the rest answer `WRONGPASS`, so failures look random and move with routing or failover. That is why a user goes to every node before any client is configured to use it.

  • ACL SETUSER on a primary reaches its replicas through the replication stream
  • A full resync copies the primary's ACL users across to the replica
  • Redis Cluster nodes share ACL users automatically over the cluster bus
  • An aclfile only needs the service users, and default keeps requirepass
  • CONFIG REWRITE also writes ACL users into a configured aclfile
  • request_policy:all_nodes means the server itself forwards ACL SETUSER

Assumes Redis 8.10; ACL LOAD has accepted # comment lines in an ACL file since 8.8, and ACL SAVE does not keep them.