When you want to connect your Redis from a remote host using Redis Tools, you need to make following settings are configured:
I assume you have already installed Redis on your server if you not you can follow this post – How to Install and Secure Redis on Ubuntu 22.04?
Binding Redis to Allow Connect from your Bastion host:
By Default, Redis only allows access from localhost, we need to change Redis configuration to allow incoming connection from the host server.
Open the configuration file and update the bind option:
sudo nano /etc/redis/redis.conf
Replace f <XXX.XXX.XXX.XXX> with you Bastion host public IP address.
bind <XXX.XXX.XXX.XXX> ::1
If adding public address giving you issue you can use the 0.0.0.0, but you will have too careful here because it will open connection to everyone. before doing this first make sure that the Redis has configured with Strong Password and make sure that Redis host server is not accessible publicly using Firewalls.
Restart the Redis to reflect new changes:
sudo systemctl restart redis
Test if the given changes are working using netstat:
sudo netstat -lnp | grep redis
If netstat is not available on your server then installed using following command:
sudo apt install net-tools
Table of Contents
Using Host & port Option:
Replace XXX.XXX.XXX.XXX with your Redis host server public/private IP.
redis-cli -h XXX.XXX.XXX.XXX -p 6379
Using Host URI Option:
redis-cli -u redis://password@XXX.XXX.XXX.XXX:6379
Conclusion:
We configured the Redis Access points and tried connecting from Remote to Redis Server using Redis Tools.
The reason of writing this post is that I had to setup very simile architecture to one my Web Application to handle WebSocket Connections.