0
0
Redisquery~5 mins

Network security (bind, protected-mode) in Redis

Choose your learning style9 modes available
Introduction

Network security settings in Redis help keep your data safe by controlling who can connect to your Redis server.

When you want to allow only certain computers to access your Redis server.
When you want to prevent unauthorized users from connecting to Redis.
When you are running Redis on a public or shared network.
When you want to quickly secure Redis without complex firewall rules.
Syntax
Redis
bind <ip-address> [<ip-address> ...]
protected-mode <yes|no>

bind tells Redis which IP addresses to listen on for connections.

protected-mode is a safety feature that blocks access if no password or bind is set.

Examples
This makes Redis accept connections only from the local computer.
Redis
bind 127.0.0.1
Redis listens on both the local computer and a specific local network IP.
Redis
bind 192.168.1.100 127.0.0.1
Enables protected mode to block unsafe connections.
Redis
protected-mode yes
Disables protected mode, allowing connections without restrictions (not recommended).
Redis
protected-mode no
Sample Program

This configuration makes Redis accept connections only from the local machine and enables protected mode for safety.

Redis
# redis.conf example
bind 127.0.0.1
protected-mode yes
OutputSuccess
Important Notes

Always use bind to limit Redis to trusted IP addresses.

Protected mode is on by default in recent Redis versions for safety.

If you disable protected mode, make sure to secure Redis with a password or firewall.

Summary

Use bind to control which IP addresses can connect to Redis.

protected-mode helps prevent unauthorized access when Redis is not secured.

These settings are simple but important steps to keep your Redis server safe.