To connect to a remote Redis server, you can use the “redis-cli” command with the “connect” option. This option allows you to specify the host and port of the remote Redis server you want to connect to.
You can run the command in the command line by typing:
$ redis-cli -h host -p port
Where “host” is the IP address or hostname of the remote Redis server, and “port” is the port number that the Redis server is listening on (the default is 6379).
For example, to connect to a remote Redis server running on IP address 10.0.0.1 and port 6380, you would run the following command:
$ redis-cli -h 10.0.0.1 -p 6380
You can also use the python redis library to connect to the remote Redis server.
import redis
r = redis.Redis(host='remote_host', port=6380, db=0)
Where “remote_host” is the IP address or hostname of the remote Redis server, and “port” is the port number that the Redis server is listening on (the default is 6379).
It is also possible to add a password in the redis connection string.
import redis
r = redis.Redis(host='remote_host', port=6380, db=0, password='your_password')