Redis requires authentication when a password is set with the requirepass configuration. Fix this error by either authenticating with your password before running commands or configuring your Redis client to include credentials.
This error occurs when Redis has password protection enabled (via the requirepass configuration directive) and a client attempts to execute commands without first authenticating. Redis acts as a security gatekeeper—any client must send an AUTH command with the correct password before executing any other command. This is a fundamental security feature to prevent unauthorized access to your data. When Redis returns "NOAUTH Authentication required," it means your client successfully connected to the Redis server, but the server rejected the command because authentication hasn't been completed yet. This commonly happens in development when switching from unsecured to password-protected Redis, or in production when credentials are misconfigured in your application.
First, check if your Redis instance actually has password protection enabled. Connect with redis-cli and check the requirepass config:
redis-cli
127.0.0.1:6379> CONFIG GET requirepassIf the second value is empty string or "", authentication is not enabled. If it shows a password string, authentication is active and you must authenticate before other commands.
If password protection is enabled, authenticate interactively:
redis-cli
127.0.0.1:6379> AUTH yourpassword
OK
127.0.0.1:6379> PING
PONGReplace "yourpassword" with your actual Redis password. Once AUTH succeeds, you can run any command.
For quick CLI operations without interactive prompt, pass password with -a flag:
redis-cli -a yourpassword PING
redis-cli -a yourpassword GET mykey
redis-cli -a yourpassword SET mykey "value"Note: Using -a flag shows the password in your shell history. For sensitive environments, prefer interactive authentication.
Most Redis client libraries automatically authenticate if you include the password in the connection string or configuration:
Node.js (ioredis):
const redis = require('ioredis');
const client = new redis({
host: '127.0.0.1',
port: 6379,
password: 'yourpassword' // Will auto-send AUTH
});Node.js (redis client):
const { createClient } = require('redis');
const client = createClient({
socket: {
host: 'localhost',
port: 6379,
},
password: 'yourpassword'
});
await client.connect();Python (redis-py):
import redis
client = redis.Redis(host='localhost', port=6379, password='yourpassword')
client.ping()Java (Jedis):
Jedis jedis = new Jedis("localhost", 6379);
jedis.auth("yourpassword");
jedis.ping();Check your client library's documentation for the exact syntax. Most modern clients accept password in the connection URL.
If using a connection URL or URI, include the password before the host:
redis://:[password]@[host]:[port]
redis://:[yourpassword]@localhost:6379Note the colon after redis:// and the @ separator before the host. Some clients like ioredis require this exact format.
If you've lost the password and need access, you must:
1. Stop the Redis server:
redis-cli shutdown2. Edit redis.conf (usually in /etc/redis/ or the config directory):
# Find and comment out this line:
# requirepass youroldpassword
# Or remove the line entirely3. Restart Redis:
redis-server /path/to/redis.conf4. Now you can connect without password:
redis-cli
127.0.0.1:6379> PING
PONGWarning: This temporarily removes authentication. Set a new password immediately and update your application configuration.
Cloud-Hosted Redis (AWS ElastiCache, Azure Cache, Upstash, etc.):
Cloud Redis instances typically have authentication enabled by default. When you provision a managed Redis instance, the service generates a password or token. Make sure to:
1. Extract the password/token from your cloud dashboard
2. Include it in your connection string (many cloud services provide this)
3. Update any CI/CD secrets or environment variables with the credentials
4. Test the connection before deploying
AWS ElastiCache Special Case:
If you recently provisioned or updated an ElastiCache cluster, AWS may have auto-scanned and modified the requirepass setting. In this case, you may need to reboot the Redis cluster from the AWS console to restore the original configuration.
Security Best Practices:
- Never hardcode passwords in source code; use environment variables
- Rotate passwords regularly in production
- Use strong passwords (16+ characters, mixed case, numbers, symbols)
- For sensitive applications, consider VPC-only Redis instances instead of password-only protection
- Consider using Redis ACLs (ACL USERS, ACL SETUSER) for fine-grained access control in Redis 6+
ERR fsync error
How to fix "ERR fsync error" in Redis
CLUSTERDOWN The cluster is down
How to fix 'CLUSTERDOWN The cluster is down' in Redis
ERR Job for redis-server.service failed because a timeout was exceeded
Job for redis-server.service failed because a timeout was exceeded
ERR Unbalanced XREAD list of streams
How to fix "ERR Unbalanced XREAD list" in Redis
ERR syntax error
How to fix "ERR syntax error" in Redis