I can ping pong Redis on the server:
# redis-cli ping
PONG
But remotely, I got problems:
$ src/redis-cli -h REMOTE.IP ping
Another possibly helpful note.
Redis can be bound to multiple IPs - that's very helpful when you don't want to open it to entire world (0.0.0.0
) but only make it accessible in local networks.
sudo nano /etc/redis/redis.conf
bind
setting:bind 127.0.0.1 10.0.0.1
sudo service redis-server restart
Now you can easily access redis from other computers in same network, e.g.
redis-cli -h 10.0.0.1
A quick note that doing this without further securing your Redis server is not a good idea as it can leave you open to attack. Be sure to also implement AUTH or otherwise secure that. See http://redis.io/topics/security for details.
A quick note that if you are using AWS ec2 instance then there is one more extra step that I believe is also mandatory. I missed the step-3 and it took me whole day to figure out to add an inbound rule to security group
Step 1(as previous): in your redis.conf change bind 127.0.0.1 to bind 0.0.0.0
Step2(as previous): in your redis.conf change protected-mode yes to protected-mode no
Step3: In your current ec2 machine go to the security group. add an inbound rule for custom TCP with 6379 port and select option "use from anywhere".
Open the file at location /etc/redis.conf
Comment out bind 127.0.0.1
Restart Redis:
sudo systemctl start redis.service
Disable Firewalld:
systemctl disable firewalld
Stop Firewalld:
systemctl stop firewalld
Then try:
redis-cli -h 192.168.0.2(ip) -a redis(username)
Bind & protected-mode both are the essential steps. But if ufw is enabled then you will have to make redis port allow in ufw.
ufw status
if Status: active
then allow redis-port ufw allow 6379
vi /etc/redis/redis.conf
bind 127.0.0.1
to bind 0.0.0.0
protected-mode yes
to protected-mode no
In my case, I'm using redis-stable
Go to redis-stable path
cd /home/ubuntu/software/redis-stable
Open the redis.conf
vim redis.conf
Change the
bind 127.0.0.1
tobind 0.0.0.0
change the
protected-mode yes
toprotected-mode no
Restart the redis-server:
/etc/init.d/redis-server stop
redis-server redis.conf