Posts | About

Use Redli CLI To Connect To Redis

April 30, 2020 by Areg Sarkissian

In this article we will download and use a Go Language based Redis CLI that mimics the standard redis-cli client commands and adds TLS connection capability that will be needed when connecting to a production Redis instance.

The Redli CLI documentation can be found at redli.

Installation on macOS

tar xvf redli_0.4.4_darwin_amd64.tar.gz
mv redli /usr/local/bin/
rm redli_0.4.4_darwin_amd64.tar.gz

Note: If you get a dyld: Library not loaded message when using wget as I did, you can run brew upgrade wget to resolve the issue.

Installation on ubuntu

tar xvf redli_0.4.4_linux_amd64.tar.gz
sudo mv redli /usr/local/bin/
rm redli 0.4.4_linux_amd64.tar.gz

Connecting to local macOS Redis instance

redli -h -p 6379

By default redli connects to localhost so we could just run:

redli -p 6379

By default redli connects to port 6379 so we could also just run:


Connecting to Redis server instance running in Docker container

Assumeing the standard redis port 6379 for the Redis server instance running in the container is mapped to port 8000 on the localhost:

redli -p 8000

Connecting to the Digitalocean managed Redis instance

# the --tls option connects to managed redis database over SSL
redli --tls -h host -a password -p port

The redis-cli and redli command prompts

When we connect to the Redis server using the standard redis-cli redis client we get command prompt:>

However when we connect using the redli client we will get the following command prompt:

Connected to 5.0.8

To exit the prompt and terminate the connection session we can type Ctrl+c in the terminal.

Executing Redis commands after connecting to the Redis server

Regardless of which CLI you use to connect to the redis server the following redis commands will work the same.

Command to check the redis connection:

> ping

Example commands to set and get values:

> set name joe
> get name
> del name
(integer) 1
> get name
> set name "john doe"
> get name
"john doe"
> keys *
 1) "name"
> set f:name joe
> get f:name
> keys *
 1) "name"
 2) "f:name"
> flushdb
> keys *

How to Connect to Redis Database Clusters with redli