I can ping pong Redis on the server:
# redis-cli ping
PONG
But remotely, I got problems:
$ src/redis-cli -h REMOTE.IP ping
1- Comment out bind 127.0.0.1
2- set requirepass yourpassword
then check if the firewall blocked your port
iptables -L -n
service iptables stop
For me, I needed to do the following:
1- Comment out bind 127.0.0.1
2- Change protected-mode
to no
3- Protect my server with iptables
(https://www.digitalocean.com/community/tutorials/how-to-implement-a-basic-firewall-template-with-iptables-on-ubuntu-14-04)
Did you set the bind option to allow remote access on the redis server?
Before (file /etc/redis/redis.conf
)
bind 127.0.0.1
After
bind 0.0.0.0
and run sudo service redis-server restart
to restart the server. If that's not the problem, you might want to check any firewalls that might block the access.
Important: If you don't use a firewall (iptables, ufw..) to control who connects to the port in use, ANYONE can connect to this Redis instance. Without using Redis' AUTH that means anyone can access/change/delete your data. Be safe!
Open $REDIS_HOME/redis.conf and uncomment requirepass -YOUR-PASSWORD-HERE-
and write down your password in the specified lines.
Login to redis using redis-cli and verify your password in the database using auth -YOUR-PASSWORD-HERE-
command.
Disable protected mode by changing its string in $REDIS_HOME/redis.conf to protected-mode no
.
Search for all bind ports values and comment all of them. Just add bind 0.0.0.0
to $REDIS_HOME/redis.conf file.
Disable your firewall or open redis port.
Start redis using ./redis-server $REDIS_HOME/redis.conf
.
Check the configuration via ./redis-cli -h -YOUR-IP- -a -YOUR-PASSWORD-HERE-
.
./redis-cli -h -YOUR-IP- ping
.