Redis port Explained: Configuring the Redis Listening Port
Introduction
The port directive specifies the TCP port that Redis listens on for client connections.
By default, Redis uses port 6379, which has become the standard port for Redis deployments. In some environments, however, you may want to use a different port to avoid conflicts, run multiple Redis instances, or comply with organizational security policies.
This guide explains how the port directive works, how to change it safely, and common configuration scenarios.
Default Value
Redis listens on the following port by default:
port 6379
Clients typically connect using:
redis://localhost:6379
Syntax
port
Examples:
port 6379
port 6380
port 7000
How port Works
When Redis starts, it listens for TCP connections on the configured port.
For example:
port 6379
Applications connect using:
redis-cli -p 6379
If the port is changed:
port 6380
Clients must also use the new port.
redis-cli -p 6380
Configure the Port
Open the Redis configuration file.
sudo nano /etc/redis.conf
Locate:
port 6379
Modify it.
Example:
port 6380
Restart Redis.
sudo systemctl restart redis
Verify the Listening Port
Run:
ss -lnt | grep redis
Example output:
LISTEN 0 511 0.0.0.0:6380
Or use:
redis-cli CONFIG GET port
Example output:
1) "port"
2) "6380"
Disable TCP Connections
If Redis should accept only Unix socket connections, disable the TCP port:
port 0
When port is set to 0, Redis does not listen for TCP connections.
This is commonly used together with:
unixsocket /run/redis/redis.sock
Common Use Cases
Default Installation
port 6379
Suitable for most deployments.
Multiple Redis Instances
Instance 1
port 6379
Instance 2
port 6380
Instance 3
port 6381
Each instance listens on a different port.
Unix Socket Only
port 0
unixsocket /run/redis/redis.sock
Useful when all applications run on the same server.
Common Mistakes
Forgetting to Update Client Configuration
After changing the port, applications must connect using the new port number.
Opening the Port to the Internet
Changing the port does not secure Redis.
Always combine the port directive with:
bind
protected-mode
Authentication
Firewall rules
Assuming a Different Port Improves Security
Moving Redis from 6379 to another port may reduce automated scans, but it is not a substitute for proper authentication and network security.
Best Practices
Use the default port unless there is a specific reason to change it.
Restrict access using the bind directive and firewall rules.
Enable authentication with requirepass or ACLs.
Use Unix sockets for local-only deployments.
Document any custom port numbers for administrators and applications.
Related Articles
Redis protected-mode Explained
Conclusion
The port directive determines which TCP port Redis listens on for client connections. While the default port 6379 is suitable for most environments, administrators may change it to support multiple instances or meet deployment requirements.
Regardless of the chosen port, Redis should always be protected with proper network restrictions, authentication, and firewall rules to ensure secure operation in production environments.
Explore More
› Redis save Explained: Configuring RDB Snapshots for Data Persistence
› Redis bind Explained: Configuring Network Interfaces Securely
› Redis maxclients Explained: Configuring Maximum Client Connections
› Redis logfile Explained: Configuring Redis Log Files
› Why Do People in Southeast Asia Love Iced Drinks? The Climate, Culture, and Science Explained
› Northern vs Southern Chinese Business Culture: Key Differences Explained