skip to content

Network Exposure & TLS

bind and protected-mode decide who can reach the port, and tls-port encrypts the hop, replication and the cluster bus. Interviewers ask what an exposed default instance risks and how to harden one.

part ofRedisread it →
on this pageshow

explore

questions

6

In Redis, what do the bind and protected-mode settings each control, and what are their defaults?

level: juniorimportance: must knowfreq 52%

answer

  1. two separate gates on one port
  2. listening address versus a per-connection check
  3. a config file changes the bind default
  4. default user still without a password

basics

~10 s

bind chooses which network interfaces Redis listens on; protected-mode refuses non-loopback clients while the default user has no password. The shipped redis.conf sets bind 127.0.0.1 -::1 and protected-mode yes.

solid answer

~40 s

`bind` decides which local addresses have a listener at all. The shipped `redis.conf` has `bind 127.0.0.1 -::1`, so only the same host can connect, and the `-` means a missing IPv6 loopback does not stop startup. Start `redis-server` with no config file and the compiled default applies instead: `* -::*`, every available interface. `protected-mode` is a second check, made on each accepted connection. With `protected-mode yes`, which is the default, and no password on the `default` user, a client from anything other than a `127.*` address, `::1` or a Unix socket receives a `-DENIED` error and is disconnected. So they fail differently: with no listener on that address the TCP connection cannot open, while protected mode accepts it and then explains the refusal. Neither setting proves who the caller is.

code

plaintext · 6 lines
plaintext
127.0.0.1:6379> CONFIG GET bind
1) "bind"
2) "127.0.0.1 -::1"
127.0.0.1:6379> CONFIG GET protected-mode
1) "protected-mode"
2) "yes"

go deeper

for a junior

Recall the two shipped lines, bind 127.0.0.1 -::1 and protected-mode yes, and say in one sentence each what they control: where Redis listens, and whether it refuses outsiders.

for a middle

Explain that the compiled bind default differs from the shipped file, and state the protected-mode condition exactly: the setting is on, the default user has no password, and the peer is not local.

for a senior

Read the symptom: a failed connection points at bind or the network, while a -DENIED reply proves the listener was reached. Check live values with CONFIG GET rather than trusting the file you were handed.

for a principal

Treat both as safety nets for a mistake, not as a security design. The standard you set is a password or ACL users and a chosen address, with protected mode left on as the backstop.

## Two settings, two different questions Redis makes two separate decisions about a network client, and interview answers often merge them. - **`bind`** is decided when a listener is opened. It names the local addresses Redis listens on: the server's own interfaces, not the clients that are allowed in. - **`protected-mode`** is decided for each accepted connection. It looks at where that connection came from and whether the `default` user has a password. The `default` user is the account a new connection starts as. Out of the box it has the `nopass` flag and may run every command, so a client that gets past these two settings needs no credentials at all. ## bind: which addresses get a listener The shipped `redis.conf` contains `bind 127.0.0.1 -::1`: the IPv4 loopback and, where it exists, the IPv6 loopback. A leading `-` means Redis will not fail to start if that address does not correspond to any network interface. An address that is already in use still fails. | Line | Effect | |---|---| | `bind 127.0.0.1 -::1` | Loopback only, the shipped setting | | `bind 192.168.1.100 10.0.0.1` | Those two local addresses only | | `bind * -::*` | Every available interface | A client dialling an address with no listener cannot open a TCP connection, so it usually sees connection refused and Redis never hears about it. `bind` can also be changed at runtime with `CONFIG SET bind`. ## protected-mode: a check on each connection Redis refuses a connection when all three of these hold: 1. `protected-mode` is `yes`, which is the default. 2. The `default` user still has the `nopass` flag. 3. The peer is not local: not a `127.*` address, not `::1`, not a Unix socket. When they do, Redis writes a `-DENIED` error that explains the situation and lists the ways out, adds one to the `rejected_connections` counter in `INFO stats`, and closes the connection. Giving the `default` user a password, for instance with `requirepass`, makes the second condition false and the check stops refusing anyone. ## The defaults depend on how the server was started "Default settings" means two different things for this question. | How it was started | `bind` | `protected-mode` | Remote client sees | |---|---|---|---| | `redis-server /path/to/redis.conf`, shipped file | `127.0.0.1 -::1` | `yes` | No listener on the public address | | `redis-server` with no config file | `* -::*` | `yes` | A listener, then `-DENIED` | The second row is the one that surprises people. With no config file Redis logs `Warning: no config file specified, using the default config` and listens on every interface. On a cloud VM with a public address the port is then visible from outside, and protected mode is what stands between a stranger and the data. A package or a start script may use either form, so ask the server rather than assuming: `CONFIG GET bind` and `CONFIG GET protected-mode` from the loopback interface. ## Telling them apart from the client's side - **The connection itself fails:** no listener on that address, or something on the network in between. Look at `bind` first. - **The client connects, then receives `-DENIED`:** the listener is fine and protected mode refused. The message names the default user's missing password. - **The client connects and commands simply work:** both gates are open, and the client is running as `default` with full rights. ## What neither setting does - `bind` is not an allow-list of clients. Binding a public address admits the whole internet to that listener. - Protected mode is not authentication. Once `default` has any password it stops refusing, and from then on that password is what protects whatever addresses `bind` exposes. - Neither one encrypts anything. Traffic stays in clear text until TLS is configured, which is a separate set of settings. When remote clients are legitimate, the usual change is to add the host's private address to `bind`, give the `default` user a password and leave `protected-mode yes` where it is. The `-DENIED` message also offers `CONFIG SET protected-mode no`, but it warns you to make sure Redis is not publicly accessible first, and that option removes the backstop rather than meeting its condition.

  • If you set bind to the VM's public address and leave everything else alone, can a remote client now use Redis?
    It can reach the port but not use it. `bind` opens the listener, then protected mode refuses the connection with `-DENIED`, because `protected-mode` is still `yes` and the `default` user still has `nopass`. In Redis 8.10 naming a specific address does not switch the check off. The remote client gets in once `default` no longer has `nopass`, usually by giving it a password, or after someone sets `protected-mode no`.
  • Why does the shipped line write -::1 with a dash but 127.0.0.1 without one?
    The dash tells Redis not to fail at startup if that address does not correspond to any network interface, which covers a host with no IPv6 loopback. `127.0.0.1` has no dash, so it must be available. The dash does not forgive an address already in use by another process: that still fails.

bind decides which doors the building has; protected mode is a guard who turns outsiders away for as long as the main account has no lock. The guard never checks anyone's identity, and goes off duty the moment a lock is fitted.

  • bind lists the client addresses that are allowed to connect
  • protected-mode yes makes every client send a password
  • With no config file Redis listens on loopback only
  • Binding a specific address turns protected mode off in Redis 8.10
  • A -DENIED reply means a firewall blocked the client
open as a page

What can anyone reaching an unauthenticated Redis do, and why restrict commands with ACLs rather than rename-command?

level: middleimportance: must knowfreq 47%

basics

~20 s

Anyone reaching an unauthenticated Redis runs as the default user: reads every key, runs FLUSHALL, changes settings with CONFIG SET. Stock defaults still block MODULE LOAD, DEBUG and changing dir. rename-command is deprecated; ACLs restrict commands per user.

open as a page

How do you configure a Redis server to accept only TLS clients, and what does tls-auth-clients decide about who may connect?

level: middleimportance: should knowfreq 44%

basics

~10 s

Build with BUILD_TLS=yes, set tls-port, tls-cert-file, tls-key-file and a CA, and set port 0 to close the plain listener. tls-auth-clients then decides whether clients must present a certificate: yes by default, optional, or no.

open as a page

Redis answers -DENIED to a remote client holding a valid certificate, although bind lists the VM's private address and named ACL users have passwords: why, and what fixes it?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Protected mode is still on and the default user still has the nopass flag, so non-loopback connections are refused whatever bind, certificates or other users say. Give default a password, or resetpass it, rather than turning the check off.

open as a page

After setting port 0 and tls-port on a Redis node, which hops can still be plaintext or unauthenticated, and how do you close each one?

level: seniorimportance: should knowfreq 33%

basics

~20 s

Replicas dial out in plaintext until tls-replication yes; the cluster bus and MIGRATE stay plain, and the bus unauthenticated, until tls-cluster yes. Under a shared CA add tls-expected-peer-name, since by default any certificate chaining to that CA passes.

open as a page

How would you decide whether to run TLS on every Redis hop inside a private network, given what it costs in CPU and latency?

level: principalimportance: should knowfreq 27%

basics

~20 s

Decide per hop from who can reach it and what crosses it, then measure the cost on your own workload. TLS lowers per-instance throughput, but the cluster bus has no other authentication, so that hop rarely earns an exemption.

open as a page