Dragonfly Cloud is now available on the AWS Marketplace - Learn More

Question: What is the default port for a Redis cluster and how can it be changed?

Answer

Redis, an open-source, in-memory data structure store which supports different kinds of data structures like strings, hashes, lists, sets, etc., can operate in cluster mode. In cluster mode, several Redis instances (nodes), running on one or more physical or virtual servers, work together to provide higher levels of availability, partition tolerance, and scalability.

In a Redis cluster, each node listens for connections on two TCP ports. The first is the usual Redis TCP port that clients connect to; by default, this is 6379. The second, known as the "cluster bus," is used for node-to-node communication and defaults to port + 10000. For example, if your Redis service is running on 6379, the cluster bus will run on 16379.

If you want to change the default port on which your Redis cluster is running, you can do so by modifying the Redis configuration file (redis.conf). Here's a simple example:

# Open the configuration file with your preferred editor. Here we use nano. nano /etc/redis/redis.conf # Find the line that begins with 'port' and change its value. # For instance, to change the default port to 6380, you would modify the line to look like this: port 6380 # Save and close the file when you're done. # Then restart the Redis service for the changes to take effect. systemctl restart redis.service

This will set the main Redis service to run on port 6380 and the cluster bus on port 16380.

However, please be aware that changing the default port might affect your existing applications and services that are configured to connect to Redis on its default port. Be sure to update any references in your application code or connection strings to avoid connection issues.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost