In various scenarios, such as after creating a new cluster or upgrading the cluster, it is highly advisable to verify client connectivity to the database.

To test client connectivity:

  1. Create a Redis database and get the database endpoint, which contains the cluster name (FQDN).
  2. Try to connect to the database endpoint from your client of choice, and execute commands against the database.
  3. If the database does not respond, try to connect to the database endpoint by using the IP address rather than the FQDN; if you succeed, it means that the DNS is not properly configured. For additional details, refer to DNS.

If any issues are encountered during the connectivity test, contact our support at [email protected].

Test connecting to your database

With the Redis database created, you are ready to connect to your database to store data. You can use one of the following ways to test connectivity to your database:

  • Connecting with redis-cli, the built-in command-line tool
  • Connecting with a Hello World application using Python.

Connecting using redis-cli

Run redis-cli, located in the /opt/redislabs/bin directory, to connect to port 12000 and store and retrieve a key in database1

# sudo /opt/redislabs/bin/redis-cli -p 12000> set key1 123
OK> get key1

Connect with a simple Python app

A simple python application running on the host machine can also connect to the database1.

The following section assumes you already have python and redis-py (python library for connecting to Redis) configured on the host machine running the container. You can find the instructions to configure redis-py on the github page for redis-py.

In the command-line Terminal, create a new file called


Paste the following into a file named

import redis

r = redis.StrictRedis(host='localhost', port=12000, db=0)
print ("set key1 123")
print (r.set('key1', '123'))
print ("get key1")

Run “” application to connect to the database and store and retrieve a key using the command-line.


The output should look like the following screen if the connection is successful.

set key1 123
get key1

Test database connectivity with a simple application

You can also use a simple application to test connectivity to your database. Here is a simple python app that connects to the database by IP address. The app uses the discovery service that is compliant with Redis Sentinel API.

In the IP-based connection method, you only need the database name, not the port number. Here we simply use the discovery service that listens on port 8001 on all nodes of the cluster to discover the endpoint for the database named “db1”.

from redis.sentinel import Sentinel

# with IP based connections, a list of known node IP addresses is constructed
# to allow connection even if any one of the nodes in the list is unavailable.
sentinel_list = [
('', 8001),
('', 8001),
('', 8001)

# change this to the db name you want to connect
db_name = 'db1'

sentinel = Sentinel(sentinel_list, socket_timeout=0.1)
r = sentinel.master_for(db_name, socket_timeout=0.1)

# set key "foo" to value "bar"
print r.set('foo', 'bar')
# set value for key "foo"
print r.get('foo')

In the URL-based connection method, you need to specify the endpoint and the port number for your database.

import redis

# the URL provided to redis. Redis method comes from the database configuration
# property called "Endpoint". The endpoint URL generated by the database is a
# combination of the cluster name (FQDN) and database port number.
r = redis.Redis(

# set key "foo" to value “bar”
print(r.set('foo', 'bar'))
# set value for key "foo"