$ run as a normal user# run as root (or with sudo)
The quick answer
user default off
user app on >Long-Random-App-Password ~app:* &app:* +@connection +@read +@write -@dangerous
user admin on >Long-Random-Admin-Password ~* &* +@allbind 10.0.0.21 127.0.0.1
protected-mode yes
port 0
tls-port 6379
tls-cert-file /etc/redis/tls/redis.crt
tls-key-file /etc/redis/tls/redis.key
tls-ca-cert-file /etc/redis/tls/ca.crt
tls-auth-clients optional
aclfile /etc/redis/users.aclStep by step
- Network first —
bindonly to the private address and localhost, and a firewall rule that allows port 6379 only from the app servers. Never expose Redis to the internet. - ACL users (quick answer) —
default offdisables the old password-less user. Theappuser may read and write keys that start withapp:(~app:*), use Pub/Sub channelsapp:*, run connection commands (PING,AUTH,HELLO), and no dangerous commands (FLUSHALL,CONFIG,KEYS,DEBUG…). Make passwords long and random; store them in the secret store. The file is readable only by Redis (chown redis:redis,chmod 640). - Hashed passwords — instead of
>passwordyou can write#followed by the SHA-256 of the password, so the file does not hold the plain text. - TLS (quick answer) — certificate and key for the server name, plus the CA.
port 0turns off plain-text connections.tls-auth-clients optional= clients do not need their own certificate;yes= mutual TLS (each client needs a certificate). - Connect —
--askpassasks for the password (it is not saved in the shell history). Test what the app user may do, and list the users as admin:
redis-cli --tls --cacert /etc/redis/tls/ca.crt -h redis.example.com --user app --askpass SET app:test 1
redis-cli --tls --cacert /etc/redis/tls/ca.crt -h redis.example.com --user app --askpass SET other:test 1
redis-cli --tls --cacert /etc/redis/tls/ca.crt -h redis.example.com --user admin --askpass ACL LIST- App connection string —
rediss://(two s) means TLS:
REDIS_URL=rediss://app:Long-Random-App-Password@redis.example.com:6379/0Load it from a secret (environment variable or secret file), never from the Git repo.
- Watch denied commands — failed logins and blocked commands are in the ACL log:
redis-cli --tls --cacert /etc/redis/tls/ca.crt -h redis.example.com --user admin --askpass ACL LOG 10- Change users without restart —
ACL SETUSER …thenACL SAVEwrites the file. Rotate the app password with two passwords on the user (>newadded, later<oldremoved).
Check that it worked
ping with the app user returns PONG; SET app:test 1 returns OK but SET other:test 1 and FLUSHALL fail with NOPERM; a connection without TLS (redis-cli -h redis.example.com ping) fails; a connection without a user gets NOAUTH Authentication required (tested with Redis 7).
Common problems
| Problem | Cause | Fix |
|---|---|---|
NOPERM this user has no permissions to access one of the keys | Key pattern does not match. | Use the app: prefix in the app, or widen ~ for that user. |
Error: Connection reset by peer | Client speaks plain text to a TLS port. | --tls / rediss://; check the CA file. |
certificate verify failed | Wrong CA, or the server name is not in the certificate. | Use the right CA; connect with the name in the certificate. |
| Redis does not start after the change | ACL file syntax error, or both requirepass and aclfile. | Check the log; do not mix requirepass with aclfile. |
| Old app breaks | It only sends a password, not a user. | Upgrade the client; it must support AUTH user password. |
| Replica or Sentinel loses the connection | They also need a user and TLS settings. | masteruser/masterauth, tls-replication yes, users for Sentinel. |
Go further
- Command pages: redis-cli, openssl.
- Next how-tos: Check Redis memory and keys, Create a self-signed certificate, Allow a port only from one IP address, Generate a strong password or secret.
- Learn it: Data services at work — Redis, Secrets services — OpenSSL. Full guide: Redis.
1Why turn off the default Redis user?
The default user is used by any client that does not log in; turning it off forces every client to use its own named user.
2What does ~app:* in a Redis ACL mean?
The user may only use keys whose names start with app: — other keys are refused with NOPERM.