There are several items to check for a remote connection to work:
$ redis-cli
127.0.0.1:6379>ping
PONG
127.0.0.1:6379>
- If the password is not set in
/etc/redis/redis.conf (this is default locaion for Ubuntu 18.04, you may have it in the different localtion):
# The following line should be commented
# requirepass <some pass if any>
- if the protected mode is set to 'no' in the config:
# The following line should be uncommented
protected-mode no
- if the IP binding is open for an access from internet in the config:
# The following line should be commented
# bind 127.0.0.1 ::1
- If the Linux firewall (here for Ubuntu 18.04) allows for incoming internet traffic to go to port
6379 (the Redis default port)
# To check if Redis port is open
$ sudo ufw status
Status: active
To Action From
-- ------ ----
...
6379/tcp ALLOW Anywhere
6379/tcp (v6) ALLOW Anywhere (v6)
...
# To open the port
$ sudo ufw allow 6379/tcp
Do not forget to restart the Redis service for changes to take effect and check if it is running:
$ sudo systemctl restart redis.service
$ sudo systemctl status redis
Then to check if it works from the remote serever you can use redis-cli:
$ redis-cli -h <your-redis-server-ip>
<your-redis-server-ip>:6379> ping
PONG
<your-redis-server-ip>:6379> exit
$
If you can ping-PONG your redis server via your internet server connected as a remote server than the remote redis connection works.
Some links to help How to install and secure Redis on Ubuntu 18.04 and how to setup Ubuntu 18.04 firewall.
WARNING: the above makes your Redis data to be completely open to anybody from the internet.
To basically secure it use requirepass and protected-mode yes settings in Redis config (see above) and block the dangeroush Redis commands (see the link above), for a deeper understanding see this article and Redis site security section.
Hope it helps.