Redis logs a possible security attack from POST or Host commands
Possible SECURITY ATTACK detected. It looks like somebody is sending POST or Host: commands to Redis.Short answer
Redis writes this warning when a client sends text that looks like an HTTP request (POST or Host:) to its port. It closes that connection. A browser or scanner is talking to Redis, so the port is reachable by something it should not be. Find the source address, bind Redis to loopback, firewall the port and require authentication.
Fix it fast
1Find out which cause you have
Find who is connected to the port and which address Redis listens on.
sudo ss -tnp '( sport = :6379 )' redis-cli CONFIG GET bind redis-cli CONFIG GET protected-mode2Match what you see, then jump to its fix
- 1
ss shows a listener on 0.0.0.0 or a public IP, and the log names a remote address.Redis is reachable from the networkFix - 2
redis-cli from a machine you do not control returns PONG without AUTH, and ACL LIST shows the default user with nopass.No password, so the default user accepts anyoneFix - 3
The log shows an address of your own app server, office or monitoring tool, a single time.A browser or tool is simply pointed at the Redis portFix
- 1
What does the error look like?
Possible SECURITY ATTACK detected. It looks like somebody is sending POST or Host: commands to Redis.
Cause 1 of 3
Redis is reachable from the network
1Check
Redis is meant for trusted clients in trusted networks. If its port is open to the internet, anyone can send it anything, including FLUSHALL.
redis-cli CONFIG GET bind
sudo ss -ltn '( sport = :6379 )'2Fix
Bind Redis to the loopback interface (or the one private address the app needs) in redis.conf, restart it, and block the port in the firewall.
# redis.conf
bind 127.0.0.1
# firewall (ufw)
sudo ufw deny 6379/tcp3Verify
From another machine the port no longer answers.
nc -vz your-server-ip 6379Confirmed by redis.io
Cause 2 of 3
No password, so the default user accepts anyone
1Check
A fresh instance has a default user that is on, with no password and access to everything.
redis-cli ACL LIST2Fix
Give the default user a strong password with ACL, or define a dedicated user for the app. Then put the same password into the app's connection string.
redis-cli ACL GENPASS
redis-cli ACL SETUSER default on '>PASTE_THE_GENERATED_PASSWORD' '~*' '&*' '+@all'3Verify
An unauthenticated command is now refused.
redis-cli pingConfirmed by redis.io
Cause 3 of 3
A browser or tool is simply pointed at the Redis port
1Check
Someone typed http://host:6379 in a browser, or a health check or reverse proxy uses HTTP against the wrong port. Redis rejects it and logs the warning.
sudo grep -R '6379' /etc/nginx /etc/haproxy 2>/dev/null2Fix
Point the HTTP client at the web port. A Redis health check must speak the Redis protocol, for example redis-cli ping.
redis-cli -h 127.0.0.1 ping3Verify
The warning stops appearing for that address.
sudo tail -n 20 /var/log/redis/redis-server.logConfirmed by redis.io
How do I stop it coming back?
- Keep protected mode on and bind to loopback unless a private address is needed.
- Allow port 6379 only from your application servers in the firewall.
- Use ACL users with narrow command lists instead of one shared full-access password.
- Run Redis as an unprivileged user, never as root.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Security
AuthenticationException: your certificate validation callback returned false
System.Security.Authentication.AuthenticationException
This message means a validation callback was installed, yours or one a library added, and it returned false.
3 causes, each with a fixSecurity
SSH to an EC2 instance fails with Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
ec2-user@ec2-203-0-113-25.compute-1.amazonaws.com: Permission denied (publickey).
On EC2 this error almost always means the instance did not accept your key for that user.
3 causes, each with a fixSecurity
gcloud init cannot finish the sign-in step
Enter authorization code
gcloud init signs in through a browser.
3 causes, each with a fixSecurity
A GitHub Actions SSH deploy step cannot log in to the server
ssh: handshake failed: ssh: unable to authenticate
The runner reached your server but the server refused the login.
4 causes, each with a fixSecurity
SSH to GitHub asks to confirm the host, or hangs on that prompt
ED25519 key fingerprint is SHA256:
SSH has never seen github.com from this machine, so it asks you to trust the server key.
2 causes, each with a fixSecurity
A GUI program over SSH says it cannot open the display
cannot open display:
ssh must forward X11 and the remote sshd must allow it.
3 causes, each with a fix