PortGate

Resources · Port reference · port 6379

Port 6379 (Redis): what it is and how to secure it

Redis on port 6379 should never answer the internet. An open Redis can be turned into a shell on the server.

Check command

sudo ss -tlnp | grep 6379

Copied.

Port 6379 is Redis, and it should only listen on 127.0.0.1 or a private network. If anyone on the internet can connect to it, treat the server as at risk: an open Redis is one of the most common ways cryptominers get onto a VPS.

What port 6379 is for

Redis is an in-memory database used for caches, sessions, queues and rate limits. Laravel, Django, Rails, Node apps and WordPress object caches all talk to it. It only needs to be reachable by your own app, which almost always runs on the same server or the same private network.

Why an open Redis is dangerous

Redis has no password by default, and any client that connects can run any command. An attacker can:

  • read and delete every key, including sessions and queued jobs;
  • use CONFIG SET dir and CONFIG SET dbfilename to write a file anywhere Redis can write, such as an SSH authorized_keys file or a cron file, which turns database access into a login on the server;
  • load modules or replicate from a server they control to run code.

Bots scan the whole internet for 6379 all day, so an open Redis is usually found within hours.

Check yours

On the server, see which address Redis listens on:

sudo ss -tlnp | grep 6379

127.0.0.1:6379 is local only. 0.0.0.0:6379, *:6379 or [::]:6379 means every interface.

If Redis runs in Docker, check how the port is published:

docker ps --format '{{.Names}}  {{.Ports}}'

0.0.0.0:6379->6379/tcp is public, and UFW will not block it (see the mistakes below). Finally, test from a different machine:

redis-cli -h YOUR_SERVER_IP ping

PONG means the internet can use your Redis. A timeout or "connection refused" is what you want.

Fix it

For Redis installed with apt, set the bind address and keep protected mode on in /etc/redis/redis.conf:

bind 127.0.0.1 -::1
protected-mode yes
requirepass use-a-long-random-password

Then sudo systemctl restart redis-server and put the same password in your app's REDIS_PASSWORD.

For Docker, publish the port on loopback only, or not at all if only other containers use it:

services:
  redis:
    image: redis:7
    command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
    ports:
      - "127.0.0.1:6379:6379"

Run docker compose up -d and repeat the redis-cli test from outside. It should now time out.

If you need to reach Redis remotely

Use an SSH tunnel instead of opening the port:

ssh -L 6379:127.0.0.1:6379 you@YOUR_SERVER_IP

Your local tools then connect to 127.0.0.1:6379. For app servers on other machines, use the provider's private network and allow only those addresses.

Common mistakes

  • Trusting UFW with Docker. A port published as 6379:6379 is accepted by Docker's own iptables rules before UFW's rules run, so ufw deny 6379 does nothing.
  • Relying on protected mode. The official Redis Docker image turns protected mode off, so a published container port answers anyone.
  • A password but a public port. Passwords get brute-forced and Redis is fast. Bind to localhost and use a password.

FAQ

Is port 6379 safe to open if I set a password? Safer, not safe. Keep it on localhost or a private network and use the password as a second layer.

I found strange keys or a cron file I did not create. What now? Assume the server is compromised. Close the port first, then follow the guide on finding a cryptominer that keeps coming back.

Does Redis Sentinel need the same treatment? Yes. Port 26379 controls failover and should be private too.

How do I know if it opens again? PortGate's Server Guard lists every listening port on each heartbeat, including Docker-published ones, and alerts when a database port becomes public.