redis.exceptions.AuthenticationError: Authentication required
Fixes redis-py calls rejected because the server requires a password. Use when commands raise NOAUTH Authentication required. Not for WRONGPASS (password supplied but wrong).
TL;DR: The server requires a password and you did not send one. Pass your password via the password argument of redis.Redis (and your username via the username argument if the server uses ACLs).
redis.exceptions.AuthenticationError: NOAUTH Authentication required.Fix it
- Confirm the server requires auth: redis-cli ping. Expected: NOAUTH Authentication required.
- Provide the password value build the client as redis.Redis with host [host], port 6379, and your password supplied through the password argument. Expected: r.ping() returns True.
- Redis 6+ ACLs: also pass username=[your username]. Expected: authenticated as that user.
- Or via URL: redis.from_url() with a URL that carries your password in the userinfo section before [host]:6379/0. Expected: connects.
When this applies
- The error is NOAUTH Authentication required.
When it doesn't
- WRONGPASS: you sent a password but it is wrong; fix the value.
- Connection refused: the server is not reachable at all.
Compatibility
- redis-py 3.x/4.x/5.x; Redis 5 (requirepass) and 6+ (ACLs).
Why it happens
A server with requirepass or ACLs rejects every command until AUTH succeeds. Clients default to no password, so any secured server 401s them immediately.
Edge cases
- Special characters in the password must be URL-encoded in from_url strings.
- In from_url, the empty username slot matters: put a colon before the password in the userinfo section; omitting the colon parses differently.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.