Omonbude Emmanuel
Software Engineer
HTML/CSS/JAVASCRIPT
PYTHON
DJANGO/DJANGO REST FRAMEWORK
NODE JS
DOCKER, AWS, KUBERNATES
FIREBASE, PostgreSQL, MySQL,Mongo DB
FLUTTER
DART
ANGULAR
TYPESCRIPT

Opening Redis port to allow remote connection

Omonbude Emmanuel | April 10, 2024, 9:36 a.m.

81

Introduction

Redis is a popular in-memory data store that provides high-performance caching and data storage for applications. By default, Redis only listens on the loopback address (127.0.0.1), which means it's only accessible from the local machine. However, in many cases, you need to allow remote connections to Redis for distributed caching, clustering, or other purposes. In this post, we'll guide you through the steps to open the Redis port for remote connections.

Prerequisites

- Redis installed and running on a Linux server

Step 1: Edit Redis Configuration File

Open the Redis configuration file, usually located at /etc/redis/redis.conf, using a command like:

sudo nano /etc/redis/redis.conf

Uncomment the line starting with # bind 127.0.0.1 ::1 by removing the # symbol, and replace 127.0.0.1 with 0.0.0.0 to allow connections from any IP address.

Step 2: Restart Redis Service

Restart the Redis service to apply the changes:

sudo systemctl restart redis-server

 

Step 4: Configure Firewall Rules 

Limit access to Redis by configuring firewall rules or security groups. For example, you can use ufw (Uncomplicated Firewall) to allow incoming traffic on the Redis port (6379 by default):

sudo ufw allow redis

 

To allow only a specific ip address

in the /etc/redis/redis.conf file, 

bind myipaddress 0.0.0.0


replace myipaddress with the actual ipaddress

 

Then update the firewall, 

sudo ufw allow from myipaddress to any port 6379

replace myipaddress with the actual ipaddress


Conclusion

In this post, we've covered the steps to open the Redis port for remote connections. Remember to prioritize security by setting a strong password and enabling SSL/TLS encryption. Additionally, configure firewall rules to limit access to Redis. By following these steps, you'll be able to access Redis from remote machines and take advantage of its high-performance caching and data storage capabilities.

 

© 2024 Omonbude Emmanuel

Omonbude Emmanuel