Reference · Databases
Redis and Valkey port 6379: check bind, protected mode and passwords
A Redis or Valkey server that other machines reach without a password gives them every key and, on older versions, a way to write files. Check bind, protected-mode and ACL LIST, keep port 6379 on 127.0.0.1 and sign apps in as ACL users.
| Target artifact | The bind, protected-mode and sign-in settings (requirepass, aclfile or user lines) of a Redis or Valkey server on TCP port 6379, in /etc/redis/redis.conf or /etc/valkey/valkey.conf. |
|---|---|
| Default behaviour | The shipped configuration files listen on 127.0.0.1 and ::1 with protected-mode yes, but set no password: every connection is signed in as the default user, with every command. Without a configuration file the server listens on every interface and only protected mode keeps other machines out; the official Docker images turn it off. |
| Safe state | bind 127.0.0.1 -::1, or a private address behind a firewall when other machines need the server; protected-mode yes; no user that is on with nopass in ACL LIST; each app signed in as its own ACL user; a test from another device gets no reply, or NOAUTH. |
| Check on Linux | sudo ss -tlnp 'sport = :6379' |
| Check in redis-cli | redis-cli ACL LIST, then redis-cli CONFIG GET bind and redis-cli CONFIG GET protected-mode; valkey-cli takes the same commands |
| Check from another device | (sleep 1; printf 'PING\r\n') | nc -w 5 SERVER_IP 6379 |
| Fix on Linux | keep bind 127.0.0.1 -::1 and protected-mode yes, add ACL users in an aclfile, then sudo systemctl restart redis-server or valkey-server |
| Fix in Docker | publish with -p 127.0.0.1:6379:6379 and start the server with a configuration file that sets a password |
Read the result
Address in ss | Who can connect |
|---|---|
127.0.0.1:6379, [::1]:6379 | This computer only |
0.0.0.0:6379, *:6379, [::]:6379 | Every network the server is on; protected mode and passwords decide who gets in |
A private address, such as 10.0.0.5:6379 | Machines that can reach that network |
| Reply to the test from another device | Meaning |
|---|---|
+PONG | Open: anyone who reaches the port can read, change and delete every key. Fix it now |
-NOAUTH Authentication required. | A password is required. Keep the port closed to the internet anyway |
-DENIED and an explanation of protected mode | It listens on the network with no password; only protected mode keeps you out |
| Nothing | Not reachable from where you tested |
The one-second pause in the test command matters. In tests on Redis 6.0.16 and 7.0.15 and Valkey 7.2.13, a PING sent the moment the connection opened often left nc printing nothing, although the server had answered -DENIED; with the pause, the reply arrived every time.
ACL LIST shows the users of the access control list (ACL). nopass means no password; a # and a long hash mean a password is set; user default off means every client must sign in by name. After that, redis-cli --user NAME --askpass keeps the password out of your shell history.
Why an open port 6379 can cost the server
The Redis and Valkey security pages both say the server is designed for trusted clients inside trusted environments. A client that reaches a server with no password can:
- read every key, and delete them all with one
FLUSHALL; - point the database file elsewhere with
CONFIG SET diranddbfilename, thenSAVE: a file lands wherever the server's account can write, which Redis's security page says may lead to compromising the system. Redis 7.0 made both settings immutable at run time and blockedDEBUGandMODULEby default; - make the server a copy of an attacker's server with
REPLICAOF HOST PORT, or its older nameSLAVEOF, which the protected settings do not block. Aqua Security researchers Asaf Eitani and Assaf Morag reported on 1 February 2023 a campaign that usedSLAVEOFto deliver a malicious module, thenMODULE LOAD, on at least 1,200 servers; - run Lua scripts. CVE-2025-49844, published 3 October 2025, lets a signed-in user's crafted script trigger a memory error, a use-after-free, that can lead to remote code execution, and with no password every connection is signed in. Fixed in Redis 6.2.20, 7.2.11, 7.4.6, 8.0.4 and 8.2.2, and Valkey 7.2.11, 8.0.6 and 8.1.4.
Defaults by version
Tested on 9 November 2026 with Redis 6.0.16 from Ubuntu 22.04 and Redis 7.0.15 and Valkey 7.2.13 from Ubuntu 24.04, each listening on every interface with no password. The Ubuntu 26.04 and Docker entries come from their configuration files and documentation.
| Version and package | bind in the shipped file | Protected mode | CONFIG SET dir |
|---|---|---|---|
| Redis 6.0, Ubuntu 22.04 | 127.0.0.1 ::1 | Acts only with no bind line and no password: with bind 0.0.0.0, another address got PONG | Allowed: a client wrote a file into a folder it chose |
| Redis 7.0 and Valkey 7.2 (Ubuntu 24.04); Redis 8.0 and Valkey 9.0 (Ubuntu 26.04) | 127.0.0.1 -::1 | Refuses other addresses whenever default has no password, whatever bind says | Refused: can't set protected config |
Official Docker images redis and valkey/valkey | Not set: a port published with -p reaches the server | Off, changed when the image is built | As for the version inside |
Redis 7.0's release notes record the change: changing bind no longer turns protected mode off. Valkey ships the same values under other names: /etc/valkey/valkey.conf, the valkey account, valkey-cli and the valkey-server service. The - before ::1 lets the server start without IPv6.
Keep it on 127.0.0.1 and add ACL users
Warning Before you restart
Each app that uses the server needs its new user name and password in its own settings, or it stops working when the server restarts.
Ubuntu 24.04 and later, Redis or Valkey from the Ubuntu packages
- Check these lines in
/etc/redis/redis.conf, and remove the#in front ofaclfile:
bind 127.0.0.1 -::1
protected-mode yes
aclfile /etc/redis/users.acl- Create the file, owned by the service account, and add the users. Make each password with
openssl rand -hex 32.
sudo install -o redis -g redis -m 640 /dev/null /etc/redis/users.acl
sudo nano /etc/redis/users.acluser default off
user admin on >ADMIN_PASSWORD ~* &* +@all
user app on >APP_PASSWORD ~* &* +@all -@dangerous- Restart, then check:
sudo systemctl restart redis-server
sudo ss -tlnp 'sport = :6379'
redis-cli --user admin --askpass ACL LISTFor Valkey, use valkey as owner and group, the same names under /etc/valkey/, sudo systemctl restart valkey-server and valkey-cli. Users go in the configuration file or in an ACL file, not both, and requirepass is ignored once aclfile is set.
Ubuntu 22.04, Redis 6.0
Leave &* out of each user line: channel rules arrived in Redis 6.2, and Redis 6.0.16 answered Syntax error to &* in the test. In 6.0, naming any address in bind also turns protected mode off, so keep bind 127.0.0.1 ::1 and set the password first.
One password only: requirepass
Redis calls this the legacy method. It sets the password of the default user, and clients send only the password.
requirepass PASSWORDTake risky commands away from apps, instead of rename-command
-@dangerous removes commands such as CONFIG, DEBUG, REPLICAOF, FLUSHALL, KEYS and INFO; -@scripting removes Lua scripts. Rules apply from left to right, so -@dangerous +info gives one back. rename-command still works, but the redis.conf and valkey.conf in Ubuntu 26.04 mark it deprecated in favour of ACLs, and Redis's security page says it may be removed. Keep the enable-* settings at no: redis-cli CONFIG GET 'enable-*'.
Docker
The redis image's documentation says protected mode is off, so a port published with -p is open without a password to anyone; the Valkey image is built the same way, and published ports bypass UFW (Docker published ports). Publish on the loopback address, with a configuration file that sets requirepass or aclfile:
docker run -d --name redis -p 127.0.0.1:6379:6379 -v /srv/redis/conf:/usr/local/etc/redis redis redis-server /usr/local/etc/redis/redis.confFor Valkey, use the valkey/valkey image, valkey-server and a valkey.conf.
Troubleshooting
Apps on other machines get DENIED
Protected mode refuses them because default has no password. Leave it on: give each app an ACL user, add the private address they connect to after 127.0.0.1 -::1 on the bind line, and let only their addresses through the firewall.
ss still shows 0.0.0.0 after the change
Another copy is running: sudo ss -tlnp names the process, and docker ps lists containers.
Related guides and lookups
Sources
- Redis: security
- Redis: ACL
- Redis on GitHub: redis.conf
- Redis on GitHub: 7.0-rc1 release notes
- Redis: security advisory CVE-2025-49844
- Redis on GitHub: advisory GHSA-4789-qfc9-5f9q
- Valkey: security
- Valkey: ACL
- Valkey on GitHub: valkey.conf
- Valkey on GitHub: advisory GHSA-9rfg-jx7v-52p6
- Docker official images: redis
- Valkey on GitHub: official container Dockerfile
- Ubuntu packages: redis-server
- Launchpad: valkey in Ubuntu
- Aqua Security, Asaf Eitani and Assaf Morag: HeadCrab Redis malware