Configure Redis on Droplets so other droplets can connect

July 11, 2018 85 views
Redis Ubuntu 16.04


I'm very new to DevOps. I just configured a droplet to run Redis following this tutorial and I want to set it up so my rails apps running on other droplets (and nothing more) can connect to it. Is there a guide I can follow? So far I've seen how to secure it for local host only and how to open it for everyone.


2 Answers

Hello friend!

One easy way to do this is using a firewall. It is very important that redis not be open to the world, so be careful in doing this. There are other paths as well, this is merely the first one that came to my mind. I will lay out an example:

In this example, redis is listening on port 3000, and the other droplet that I want to connect to it has an IP address of The steps to do this via firewall would then be:

iptables -I INPUT -p tcp --dport 3000 -j DROP
iptables -I INPUT -p tcp --dport 3000 -s -j ACCEPT

This tells the firewall to drop all external incoming traffic on port 3000 unless the source IP is Then, after doing that, you could follow the instructions to open redis to the world and it would only open it to

Again, be very careful. Redis is high on the list of services scanned for by malicious actors who are looking to compromise servers to leverage them for their own use, as well as for scams where they wipe out your data and ask for a ransom to buy it back. Even a few minutes of it being exposed to the whole internet can be too many.

Kind Regards,

Thank you! I did just that :)

Have another answer? Share your knowledge.