E-NO
Redis security 16 Min Read

Redis Security Hardening with Practical Examples

calendar_today Published: 2026-11-02
update Last Updated: 2026-11-03
analytics SEO Efficiency: 100%
Technical guide illustration for Redis Security Hardening with Practical Examples.

Intro

Redis is widely used for caching, session storage, real-time analytics, and message brokering. Its speed and simplicity make it a favorite among developers and operations teams. However, Redis was designed to run in trusted environments, and many deployments expose it to security risks through weak access controls, open network ports, and mishandled secrets. A single exposed Redis instance can lead to data loss, unauthorized access, or even full server compromise via techniques like writing SSH keys or crontab entries.

This guide provides practical, hands-on steps to harden a Redis deployment. You will learn how to establish a version and environment baseline, implement scoped configuration changes safely, verify your security posture with concrete commands and expected outputs, plan for failure modes and recovery, and maintain an operations checklist for ongoing security. Each major step includes command examples and configuration snippets that you can adapt to your environment. By the end, you will have a hardened Redis setup that reduces attack surface while preserving performance and operational simplicity.

The process of hardening Redis benefits from a structured approach. As with any infrastructure change, breaking down the work into clear phases - research, configuration, verification, and review - reduces rework and ensures that changes are deliberate and auditable. A narrow, measurable pilot focused on a specific Redis instance or a single security control allows you to validate changes locally before rolling them out more broadly. This guide reflects that mindset: every recommendation is scoped to a clear goal and accompanied by an observable check.

Version and Environment Inventory

Before making any security changes, you need a complete picture of your Redis installation and its surroundings. This inventory serves several purposes: it helps you identify which Redis version you are running (and thus which security features are available), it reveals how Redis is configured and exposed on the network, and it establishes a baseline against which you can measure the impact of your hardening changes.

Determine Redis version and build details

Connect to your Redis instance using redis-cli and issue the INFO command. The output includes the Redis version, build details, and other runtime information. Run the following command, replacing 127.0.0.1 and 6379 if your instance listens on a different address or port:

redis-cli -h 127.0.0.1 -p 6379 INFO server

You should see output similar to this (exact values may differ):

# Server
redis_version:6.2.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:6b2060f0f0a0e0b0
redis_mode:standalone
os:Linux 5.4.0-105-generic x86_64
arch_bits:64

Note the redis_version. Many security features, such as ACLs, protected mode, and TLS, were introduced or improved in later versions. For example, ACLs were introduced in Redis 6.0 and are not available in earlier releases. If you are running an older version, consider upgrading to a supported release before applying the hardening steps described here, because some protections cannot be backported.

Identify Redis configuration file and runtime settings

Redis can be configured via a configuration file (usually /etc/redis/redis.conf on Linux) or via command-line arguments. To see the path of the configuration file used by a running instance and the current values of key security-related settings, use CONFIG GET commands. For example:

redis-cli CONFIG GET dir
redis-cli CONFIG GET protected-mode
redis-cli CONFIG GET requirepass
redis-cli CONFIG GET bind

Each command returns a list with the parameter name and its value. For instance:

1) "dir"
2) "/var/lib/redis"

By examining these settings, you can quickly see dangerous misconfigurations: protected-mode set to no, no requirepass (empty password), bind set to 0.0.0.0 or :: (listening on all interfaces), and dir pointing to a writable directory that could be abused for unauthorized writes.

Understand network exposure

Determine which network interfaces Redis is listening on. Use the CONFIG GET bind output or inspect the process listening sockets. On Linux, use ss to see listening sockets:

ss -tulpn | grep redis

If you see output like 0.0.0.0:6379 or :::6379, Redis is accepting connections on all interfaces. This is a critical exposure risk, especially if the host has a public IP address or is reachable from untrusted networks.

Also check firewall rules to understand which clients can actually reach the Redis port. For example, on systems using iptables:

sudo iptables -L -n | grep 6379

If no rules exist, the port is open to all traffic that can reach the host.

Document your topology and access patterns

Make a list of all clients that legitimately connect to Redis: application servers, monitoring systems, admin workstations, etc. Note their source IP addresses or networks, the commands they need to run, and the keys or key patterns they access. This information is essential for designing ACLs and network restrictions that do not break legitimate workloads.

Finally, record the Redis data persistence settings (save, appendonly). If Redis is configured to save snapshots or an append-only file, the directory must be protected because the files contain all data in plaintext. Use:

redis-cli CONFIG GET save
redis-cli CONFIG GET appendonly
redis-cli CONFIG GET dir

Typical output:

1) "save"
2) "900 1 300 10 60 10000"
3) "appendonly"
4) "no"
5) "dir"
6) "/var/lib/redis"

This inventory forms the basis for the safe configuration path in the next section. You should always complete this inventory before making changes, and keep a record of the initial values so you can roll back if needed.

Safe Configuration Path

The hardening process should be incremental and scoped. Rather than applying all changes at once, start with the most critical and easily verifiable controls, test each change in isolation, and then proceed to the next. This section guides you through a recommended order, with concrete configuration steps and examples.

1. Enable protected mode and bind to specific interfaces

Redis has a built-in protected-mode that, when enabled (default), rejects connections from clients that are not explicitly authenticated or not from loopback interfaces if the instance is not configured with a bind address or password. Ensure that protected-mode is set to yes and that bind restricts listening to only the necessary interfaces. For example, if your application runs on the same host, bind to loopback only:

# redis.conf
protected-mode yes
bind 127.0.0.1

If your application runs on another host in a private network, bind to a private IP, such as:

bind 10.0.0.5

Avoid binding to 0.0.0.0 or :: unless absolutely necessary and protected by network ACLs.

After changing the configuration, restart Redis and verify the listening addresses with ss:

ss -tulpn | grep redis

Expected output shows only the specified interface, e.g., 127.0.0.1:6379.

2. Set a strong requirepass or, preferably, use ACLs

Enable authentication so that only authorized clients can issue commands. For simple setups, a single requirepass can be used. Set a strong passphrase (e.g., 32+ random characters) in the configuration file:

requirepass "your-strong-password-here"

Restart Redis and test that you are prompted for authentication:

redis-cli PING

Without authentication, you should see (error) NOAUTH Authentication required. Then authenticate and run PING:

redis-cli -a 'your-strong-password-here' PING

Expected output: PONG.

However, requirepass grants full access to any client that knows the password. For finer-grained control, use ACLs (available in Redis 6+). With ACLs, you can create multiple users with different permissions. For example, create an administrative user and a read-only user for your application:

# In redis.conf or using ACL SETUSER via redis-cli
user admin on >strong-admin-password ~* +@all
user appuser on >app-password ~cache:* +get +set +del

The admin user has full access to all keys and commands. The appuser can only access keys starting with cache: and can only run GET, SET, and DEL. Disable the default user to prevent passwordless access:

user default off

Test the ACL with redis-cli:

redis-cli -a 'app-password' --user appuser SET cache:test "value"
redis-cli -a 'app-password' --user appuser GET cache:test
redis-cli -a 'app-password' --user appuser SET other:test "value"

The first two commands succeed; the third returns (error) NOPERM this user has no permissions to access one of the keys used as arguments.

3. Use TLS for transport encryption

If Redis traffic traverses untrusted networks, enable TLS. Redis can be compiled with TLS support via BUILD_TLS=yes, and many distributions provide TLS-enabled builds. Configure TLS in redis.conf:

port 0
tls-port 6379
tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key
tls-ca-cert-file /path/to/ca.crt
tls-auth-clients no # or yes if client certificate authentication is required

Restart Redis and connect using redis-cli with TLS options:

redis-cli --tls --cacert /path/to/ca.crt

Verify the connection is encrypted. Note: TLS adds overhead; for internal networks, binding to private IPs may be sufficient.

4. Disable dangerous commands

Redis includes commands that can be abused to read or write arbitrary files on the server (CONFIG, EVAL, DEBUG, etc.). You can rename or disable them to reduce risk. For example, to disable CONFIG, EVAL, and DEBUG entirely (set to empty string to disable):

rename-command CONFIG ""
rename-command EVAL ""
rename-command DEBUG ""

Or rename to an unpredictable string if you need to use them:

rename-command CONFIG "b840fc02d524045429941cc15f59e41cb7be6c52"

After restart, try to run the disabled command to confirm it is rejected:

redis-cli CONFIG GET maxmemory

Expected: (error) ERR unknown command 'CONFIG' (or the new name if renamed).

5. Set appropriate file permissions and ownership

Ensure the Redis configuration file, data directory, and log files are readable only by the Redis user and root. For example, if Redis runs as user redis:

sudo chown redis:redis /etc/redis/redis.conf
sudo chmod 600 /etc/redis/redis.conf
sudo chown -R redis:redis /var/lib/redis
sudo chmod 750 /var/lib/redis

Also ensure the data directory is not writable by other users, because Redis can be used to write arbitrary files (e.g., via CONFIG SET dir, SAVE, or BGSAVE).

6. Use a dedicated, unprivileged user

Never run Redis as root. Redis should run under a dedicated OS user with no shell and minimal privileges. Most package installations create a redis user. Verify with ps:

ps aux | grep redis

Ensure the process owner is not root. If it is, change it via the init script or systemd unit.

7. Apply operating system and network protections

  • Set up a host firewall to allow only trusted client IPs to access the Redis port.
  • Consider using iptables or ufw. For example, with ufw:
sudo ufw allow from 10.0.0.10 to any port 6379
sudo ufw enable
  • If Redis is on a public cloud, use security groups or network ACLs to restrict access.
  • Run Redis in a private subnet behind a VPN or bastion host if possible.

8. Enable logging and monitoring

Configure Redis to log to a file with an appropriate level. Set:

loglevel notice
logfile /var/log/redis/redis.log

Ensure the log directory is writable by the Redis user. Monitor logs for authentication failures and suspicious commands.

Verification and Diagnostics

After applying each hardening change, verify that it works as intended and does not break legitimate operations. The following checks provide concrete commands and expected results.

1. Authentication and ACL checks

Test that unauthenticated connections are rejected:

redis-cli PING

Expected: (error) NOAUTH Authentication required. (if requirepass or ACL enabled).

If using ACLs, verify user permissions with ACL WHOAMI after authenticating as a user:

redis-cli -a 'app-password' --user appuser ACL WHOAMI

Expected: "appuser".

Attempt to execute a forbidden command to confirm denial:

redis-cli -a 'app-password' --user appuser FLUSHALL

Expected: (error) NOPERM this user has no permissions to run the 'flushall' command.

2. Network exposure checks

Use ss or netstat to confirm Redis is listening only on intended interfaces:

ss -tulpn | grep redis

Expected output shows the specific IP, not 0.0.0.0.

From a remote machine, attempt to connect to the Redis port (replace redis-host with the actual hostname or IP):

redis-cli -h redis-host -p 6379 PING

If the firewall and bind are correctly configured, the connection should be refused or time out. If it prompts for a password, network access is allowed but authentication is required.

3. Dangerous command checks

Try to run a renamed or disabled command:

redis-cli CONFIG GET maxmemory

Expected: (error) ERR unknown command 'CONFIG'.

4. File permission checks

List the permissions of key files:

ls -l /etc/redis/redis.conf /var/lib/redis

Ensure the configuration file is -rw------- (600) owned by redis, and the data directory is drwxr-x--- (750) owned by redis.

5. TLS verification

If TLS is enabled, use openssl s_client to verify the certificate:

echo | openssl s_client -connect redis-host:6379 -servername redis-host 2>/dev/null | openssl x509 -noout -subject -issuer

You should see the certificate subject and issuer confirming a valid chain.

6. Runtime configuration audit

Use CONFIG GET to retrieve current security-related settings and compare against your expected baseline. For example:

redis-cli CONFIG GET protected-mode
redis-cli CONFIG GET bind
redis-cli CONFIG GET requirepass
redis-cli CONFIG GET rename-command

Review the outputs for any unexpected values.

7. Log inspection

Check the Redis log for authentication failures or errors after restarting:

sudo tail -n 50 /var/log/redis/redis.log

Look for lines like Authentication required or Bad ACL indicating attempted unauthorized access.

Failure Modes and Recovery

Hardening changes can sometimes cause unintended outages or lock out legitimate users. This section covers common failure modes and how to recover from them.

Lockout due to lost or misconfigured credentials

If you forget the requirepass or ACL user passwords, you may not be able to authenticate. To recover, you can temporarily disable authentication by modifying the configuration file (if you have OS-level access) or starting Redis with a temporary configuration. For example, stop Redis, edit redis.conf to comment out requirepass or set user default on without a password, restart, and then reset credentials. Always do this via a secure console session and re-enable authentication immediately.

Breaking application connectivity

Changing bind or firewall rules can accidentally block valid application servers. If your application starts throwing connection errors after a change, first check the application error logs and then verify Redis reachability from the application host using redis-cli -h <redis-host> ping. If reachable but authentication fails, check the credentials. If the connection is refused, check bind and firewall rules. Roll back the specific change: restore the previous bind value or firewall rule, and restart Redis or reload firewall.

Disabling required commands

If you disable a command that your application or administration tooling needs, you will see errors like unknown command in client logs. For example, monitoring tools may use CONFIG GET or INFO. To recover, re-enable the command in the configuration (remove the rename-command entry) and restart Redis, or temporarily rename it to an available command and update the client.

TLS misconfiguration

If TLS is enabled but the certificate paths are incorrect or the certificate is invalid, Redis may fail to start. Check the Redis log for TLS errors. Correct the certificate paths and ensure permissions. Alternatively, temporarily disable TLS by restoring the pre-TLS configuration file and restarting.

Data loss due to misconfigured persistence

Some hardening guides recommend disabling persistence to reduce risk of file writes. However, if you disable save and appendonly, data will not survive restarts. If you accidentally disable persistence and then restart Redis, you will lose all data. To recover, re-enable persistence and restore data from a backup or from a replica if available. Always ensure you have a backup before making persistence changes.

Rollback plan

Before applying any change, save a copy of the current configuration file and note the current runtime configuration. For example:

sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.bak-$(date +%Y%m%d)

If a change causes problems, restore the backup and restart Redis:

sudo cp /etc/redis/redis.conf.bak-YYYYMMDD /etc/redis/redis.conf
sudo systemctl restart redis

Test the rollback in a staging environment first.

Common Pitfalls and Mistakes

Beyond the failure modes above, there are several common mistakes that administrators make when hardening Redis. Understanding why these happen and how to avoid them can prevent security gaps.

Relying on bind as a replacement for authentication

Why it happens: Administrators assume that binding Redis to a specific interface is sufficient, because only trusted hosts can reach that interface. However, if another service on the same host is compromised, or if the network is not properly segmented, an attacker can reach Redis from the bound interface.

How to avoid or recover: Always combine bind with authentication (requirepass or ACLs) even on private networks. Defense in depth is essential. If you discover that authentication is missing, add it immediately and restart Redis.

Ignoring the default user

Why it happens: When ACLs are introduced, many administrators create new users but forget to disable the default user. The default user initially has full permissions without a password, effectively leaving the instance open.

How to avoid or recover: Always include user default off in your ACL configuration. Verify with ACL LIST that no passwordless user exists.

Disabling persistence without understanding the impact

Why it happens: In an effort to prevent Redis from writing files to disk (which could be abused), administrators disable save and appendonly. They may not realize that this means data is only in memory and will be lost on restart.

How to avoid or recover: If you must disable persistence for security reasons, ensure you have a replica or another data source that can repopulate the cache. Alternatively, keep persistence enabled but restrict the directory permissions so only the Redis user can write.

Over-permissive ACLs

Why it happens: To avoid breaking applications, administrators grant broad permissions like +@all to application users. This defeats the purpose of ACLs.

How to avoid or recover: Start with minimal permissions required by the application, test in staging, and gradually expand only when necessary. Use ACL GETUSER <username> to review permissions and adjust as needed.

Not updating clients after renaming commands

Why it happens: Renaming commands like CONFIG or FLUSHALL is a good practice, but if any legitimate tool or script still uses the original command name, it will break.

How to avoid or recover: Before renaming, audit all client code and monitoring tools for command usage. Update them to use the new name, or use a controlled rollout. If something breaks, you can temporarily rename the command back or provide the new name to the client.

Forgetting to secure configuration files

Why it happens: The Redis configuration file often contains plaintext passwords or secrets. If it is world-readable, any local user can read it.

How to avoid or recover: Set permissions to 600 and owner to the Redis user. Periodically audit file permissions with ls -l /etc/redis/redis.conf and similar.

Operations Checklist

Use the following checklist for regular security audits and when deploying new Redis instances.

Initial hardening checklist

ItemCommand / CheckExpected Result
Redis version is supported (6.0+ recommended)redis-cli INFO serverredis_version >= 6.0
Protected mode enabledredis-cli CONFIG GET protected-modeyes
Bind to specific interfacesredis-cli CONFIG GET bindSpecific IP(s), not 0.0.0.0
Authentication enabledredis-cli PING without authNOAUTH error
ACL configured (6+)redis-cli ACL LISTLists users with on and permissions
Dangerous commands disabled/renamedredis-cli CONFIG GET rename-commandShows renamed/disabled mappings
TLS enabled (if needed)redis-cli --tls PINGPONG
File permissions tightls -l /etc/redis/redis.conf-rw------- redis redis
Running as unprivileged userps aux | grep redisUser is redis or similar, not root
Firewall rules restrict portsudo ufw status or iptables -LAllow only trusted IPs
Logging enabledredis-cli CONFIG GET logfilePath to log file

Accountability: The responsible engineer for each checklist item is the DBA or Operations Lead. Each item should be verified at initial deployment and after every configuration change. The entire checklist is reviewed quarterly.

Ongoing review checklist

  • Review Redis logs weekly for authentication failures or unusual commands.
  • Rotate passwords and certificates periodically (e.g., every 90 days).
  • Apply security patches and upgrade Redis to latest stable version.
  • Re-audit ACLs when application access requirements change.
  • Test backup and restore procedures regularly.
  • Review network access rules after infrastructure changes.
  • Run a configuration comparison against a known-good baseline (e.g., using redis-cli CONFIG GET * and diff).

Accountability: The Security Officer owns the review schedule, and the DBA executes the technical items. Reviews occur monthly, with exception reports generated for any deviations.

Conclusion

Hardening Redis requires a methodical approach: start with a complete inventory of your version, configuration, and network exposure; then apply changes in a safe, scoped order, verifying each one before moving on. By enabling protected mode, binding to specific interfaces, implementing strong authentication with ACLs, encrypting traffic with TLS when necessary, disabling dangerous commands, and enforcing strict file permissions, you significantly reduce the attack surface of your Redis deployment.

Verification is not a one-time event. Use the commands provided in the "Verification and Diagnostics" section to confirm that each control is effective and that legitimate clients can still operate. Plan for failure: always have a rollback plan and backups, and know how to recover from common missteps.

Finally, treat security as an ongoing process. Add the operations checklist to your routine maintenance and review it whenever infrastructure changes. Redis security hardening is a continuous practice, and the steps outlined here give you a solid foundation to build upon. Implement these changes in a staging environment first, then roll out to production with confidence.

Article Quality Score

Reader usefulness 100%
  • check_circle Reader-ready guide
  • check_circle Practical examples included
  • check_circle Clean SEO article URL