0
0
Redisquery~5 mins

Port and bind address in Redis

Choose your learning style9 modes available
Introduction

Port and bind address tell Redis where to listen for connections. This helps control who can connect to the Redis server.

When you want Redis to accept connections only from your computer.
When you want Redis to be accessible from other computers on your network.
When you want to change the default port Redis listens on to avoid conflicts.
When you want to secure Redis by limiting which IP addresses can connect.
Syntax
Redis
bind <ip-address> [<ip-address> ...]
port <port-number>

The bind directive sets which IP addresses Redis listens on.

The port directive sets the TCP port number Redis uses (default is 6379).

Examples
Redis listens only on the local computer (localhost) on port 6379.
Redis
bind 127.0.0.1
port 6379
Redis listens on all network interfaces on port 6380.
Redis
bind 0.0.0.0
port 6380
Redis listens on two IP addresses: one local and one on the local network.
Redis
bind 192.168.1.100 127.0.0.1
port 6379
Sample Program

This configuration makes Redis listen only on the local machine on the default port.

Redis
# redis.conf example
bind 127.0.0.1
port 6379
OutputSuccess
Important Notes

If you set bind to 0.0.0.0, Redis listens on all network interfaces, which can be a security risk.

Changing the port can help if another program uses the default Redis port 6379.

Always restart Redis after changing bind or port settings for changes to take effect.

Summary

Port tells Redis which number to listen on for connections.

Bind address tells Redis which IP addresses to accept connections from.

Use these settings to control access and avoid conflicts.