How to fix ERR operation not permitted in Redis
This error occurs when a Redis command is blocked by authentication, ACL permissions, or replica mode restrictions. It typically happens when credentials are missing, user permissions are insufficient, or you're trying to write to a read-only replica.
Quick fix
Fixes ERR operation not permitted
redis-cli
> COMMAND- Verify Redis requires authentication with "AUTH"
- Check current user and ACL permissions (Redis 6.0+)
- Grant necessary command permissions
- Ensure client re-authenticates on reconnection
redis-cli> COMMANDERR operation not permitted
What this error means
Redis returns this error when the requested operation is not allowed under the current security configuration. The most common cause is missing or invalid authentication, but it can also indicate insufficient user permissions in Redis 6.0+ ACL (Access Control List) settings, or an attempt to write to a read-only replica instance.
Typical symptoms
- Commands fail with 'ERR operation not permitted' error message
- Application cannot authenticate with Redis server
- Write operations fail while read operations succeed (read-only replica)
- User has insufficient ACL permissions for specific commands or keys
- Connection works initially but fails after timeout/reconnection
Common causes
- Missing or invalid password when connecting to a requirepass-protected Redis server
- Client library not re-authenticating after connection timeout or reconnection
- User lacks necessary permissions in Redis ACL configuration
- Attempting write operations on a read-only replica instance
- Key access restricted by ACL key patterns that don't match the operation
- Volume or file permission issues when running Redis in a container
How to fix "ERR operation not permitted"
Connect to Redis and check if authentication is required:
redis-cli
> COMMANDIf you get "ERR operation not permitted" or see a "requirepass" in config, you need to authenticate first:
redis-cli
> AUTH your_password
OK
> PING
PONGIf using a client library, ensure you pass the password in the connection options.
If you're using Redis 6.0 or newer with ACL enabled, check your current user:
redis-cli
> AUTH username password
OK
> ACL WHOAMI
"username"
> ACL LISTReview the output to see what commands your user is allowed to execute. Look for lines starting with your username showing permissions like +@read, +@write, or +@all.
If your user is missing permissions, log in as an admin (or the default user) and grant them:
# For specific commands
ACL SETUSER myuser +get +set +del
# For command categories
ACL SETUSER myuser +@read +@write
# For all commands
ACL SETUSER myuser +@all
# For key patterns
ACL SETUSER myuser ~myprefix:*
# Save changes
ACL SAVEThen reconnect with the updated credentials.
Some client libraries may not re-send the AUTH command after a network timeout. If you see intermittent "operation not permitted" errors:
Node.js (redis):
const client = redis.createClient({
host: "localhost",
port: 6379,
password: "your_password",
// Ensure auth is re-sent on reconnect
});Python (redis-py):
import redis
r = redis.Redis(
host="localhost",
port=6379,
password="your_password",
decode_responses=True
)Update to the latest version of your Redis client library.
If write operations fail but reads succeed, you may be connected to a replica:
redis-cli
> INFO replication
# Replication
role:slaveIf this shows role:slave, you're on a replica. Write operations are not permitted on replicas. Connect to the master instead:
redis-cli -h master_hostname -p 6379
> AUTH password
> SET key value
OKFor applications, ensure your write operations target the master host.
If running Redis in Docker, permission errors may occur when persisting data:
# Ensure data directory exists with correct permissions
sudo mkdir -p ~/redis/data
sudo chown -R 999:999 ~/redis/data
sudo chmod -R 700 ~/redis/data
# Run container with proper volume mount
docker run -d \
-v ~/redis/data:/data \
-p 6379:6379 \
redis:latestThe 999:999 UID/GID is the default Redis user in official images. Verify with:
docker exec <container_id> idAdvanced notes
ACL Best Practices: For production environments, create dedicated users with minimal required permissions rather than using the default user. Use key patterns to scope access (e.g., ~app:* restricts to keys prefixed with app:). Check ACL logs for unauthorized attempts: ACL LOG. Replication Setup: If using Redis replication, always write to the master and read from replicas. Some client libraries support read replicas automatically (like redis-py). TLS/mTLS: If Redis uses TLS certificates, ensure your client is configured for TLS connections as well. Legacy requirepass: Older Redis versions use requirepass in redis.conf instead of ACLs. Both mechanisms can cause this error if misconfigured.
Frequently asked questions
- What does "ERR operation not permitted" mean?
- Redis returns this error when the requested operation is not allowed under the current security configuration. 0+ ACL (Access Control List) settings, or an attempt to write to a read-only replica instance.
- How do I fix "ERR operation not permitted"?
- This error occurs when a Redis command is blocked by authentication, ACL permissions, or replica mode restrictions. It typically happens when credentials are missing, user permissions are insufficient, or you're trying to write to a read-only replica.
- What causes "ERR operation not permitted"?
- Missing or invalid password when connecting to a requirepass-protected Redis server Client library not re-authenticating after connection timeout or reconnection User lacks necessary permissions in Redis ACL configuration
- Is the "ERR operation not permitted" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.