{
  "schema_version": 2,
  "id": "operate/rs/databases/connect/test-client-connectivity",
  "title": "Test client connection",
  "url": "https://redis.io/docs/latest/operate/rs/databases/connect/test-client-connectivity/",
  "summary": "",
  "tags": [
    "docs",
    "operate",
    "rs"
  ],
  "last_updated": "2026-10-01T15:48:36+01:00",
  "page_type": "content",
  "content_hash": "5eb39d38dd33b87c237dbc5bb7b776d62f6c9f80dcc6eace2313de1a53b00888",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "In various scenarios, such as after creating a new cluster or upgrading\nthe cluster, you should verify clients can connect to the\ndatabase.\n\nTo test client connectivity:\n\n1. After you [create a Redis database](https://redis.io/docs/latest/operate/rs/databases/create), copy the database endpoint, which contains the cluster name (FQDN).\n\n    To view and copy endpoints for a database in the cluster, see the database’s **Configuration > General** section in the Cluster Manager UI:\n\n    ![View public and private endpoints from the General section of the database's Configuration screen.](https://redis.io/docs/latest/images/rs/screenshots/databases/config-general-endpoints.png)\n\n1. Try to connect to the database endpoint from your client of choice,\n    and run database commands.\n\n1. If the database does not respond, try to connect to the database\n    endpoint using the IP address rather than the FQDN. If you\n    succeed, then DNS is not properly configured. For\n    additional details, see\n    [Configure cluster DNS](https://redis.io/docs/latest/operate/rs/networking/cluster-dns).\n\nIf any issues occur when testing database connections, [contact\nsupport](https://redis.com/company/support/)."
    },
    {
      "id": "test-database-connections",
      "title": "Test database connections",
      "role": "content",
      "text": "After you create a Redis database, you can connect to your\ndatabase and store data using one of the following methods:\n\n- [`redis-cli`](https://redis.io/docs/latest/operate/rs/references/cli-utilities/redis-cli), the built-in command-line tool\n\n- [Redis Insight](https://redis.com/redis-enterprise/redis-insight/), a free Redis GUI that is available for macOS, Windows, and Linux \n\n- An application using a Redis client library, such as [`redis-py`](https://github.com/redis/redis-py) for Python. See the [client list](https://redis.io/docs/latest/develop/clients) to view all Redis clients by language."
    },
    {
      "id": "connect-with-redis-cli",
      "title": "Connect with redis-cli",
      "role": "content",
      "text": "Connect to your database with `redis-cli` (located in the `/opt/redislabs/bin` directory), then store and retrieve a key:\n\n[code example]\n\nTo connect from your own machine rather than from a cluster node, you can [install the standalone `redis-cli` binary](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/install-redis-cli) on Linux or macOS.\n\nFor more `redis-cli` connection examples, see the [`redis-cli` reference](https://redis.io/docs/latest/operate/rs/references/cli-utilities/redis-cli)."
    },
    {
      "id": "connect-with-redis-insight",
      "title": "Connect with Redis Insight",
      "role": "content",
      "text": "Redis Insight is a free Redis GUI that is available for macOS, Windows, and Linux.\n\n1. [Install Redis Insight](https://redis.io/docs/latest/develop/tools/insight).\n\n1. Open Redis Insight and select **Add Redis Database**.\n\n1. Enter the host and port in the **Host** and **Port** fields.\n\n1. Select **Use TLS** if [TLS](https://redis.io/docs/latest/operate/rs/security/encryption/tls) is set up.\n\n1. Select **Add Redis Database** to connect to the database.\n\nSee the [Redis Insight documentation](https://redis.io/docs/latest/develop/tools/insight) for more information."
    },
    {
      "id": "connect-with-python",
      "title": "Connect with Python",
      "role": "content",
      "text": "Python applications can connect\nto the database using the `redis-py` client library. For installation instructions, see the\n[`redis-py` README](https://github.com/redis/redis-py#readme) on GitHub.\n\n1. From the command line, create a new file called\n`redis_test.py`:\n\n    [code example]\n\n1. Paste the following code in `redis_test.py`, and replace `<host>` and `<port>` with your database's endpoint details:\n\n    [code example]\n\n1. Run the application:\n\n    [code example]\n\n1. If the application successfully connects to your database, it outputs: \n\n    [code example]"
    },
    {
      "id": "connect-with-discovery-service",
      "title": "Connect with discovery service",
      "role": "content",
      "text": "You can also connect a Python application to the database using the discovery service, which complies with the Redis Sentinel API.\n\nIn the IP-based connection method, you only need the database name, not the port number.\nThe following example uses the discovery service that listens on port 8001 on all nodes of the cluster\nto discover the endpoint for the database named \"db1\".\n\n[code example]\n\nFor more `redis-py` connection examples, see the [`redis-py` developer documentation](https://redis.readthedocs.io/en/stable/examples/connection_examples.html)."
    }
  ],
  "examples": [
    {
      "id": "connect-with-redis-cli-ex0",
      "language": "sh",
      "code": "$ redis-cli -h <endpoint> -p <port>\n127.0.0.1:16653> set key1 123\nOK\n127.0.0.1:16653> get key1\n\"123\"",
      "section_id": "connect-with-redis-cli"
    },
    {
      "id": "connect-with-python-ex0",
      "language": "sh",
      "code": "vi redis_test.py",
      "section_id": "connect-with-python"
    },
    {
      "id": "connect-with-python-ex1",
      "language": "python",
      "code": "import redis\n\n    # Connect to the database\n    r = redis.Redis(host='<host>', port=<port>)\n\n    # Store a key\n    print(\"set key1 123\")\n    print(r.set('key1', '123'))\n\n    # Retrieve the key\n    print(\"get key1\")\n    print(r.get('key1'))",
      "section_id": "connect-with-python"
    },
    {
      "id": "connect-with-python-ex2",
      "language": "sh",
      "code": "python redis_test.py",
      "section_id": "connect-with-python"
    },
    {
      "id": "connect-with-python-ex3",
      "language": "sh",
      "code": "set key1 123\n    True\n    get key1\n    123",
      "section_id": "connect-with-python"
    },
    {
      "id": "connect-with-discovery-service-ex0",
      "language": "python",
      "code": "from redis.sentinel import Sentinel\n\n# with IP based connections, a list of known node IP addresses is constructed\n# to allow connection even if any one of the nodes in the list is unavailable.\nsentinel_list = [\n('10.0.0.44', 8001),\n('10.0.0.45', 8001),\n('10.0.0.46', 8001)\n]\n\n# change this to the db name you want to connect\ndb_name = 'db1'\n\nsentinel = Sentinel(sentinel_list, socket_timeout=0.1)\nr = sentinel.master_for(db_name, socket_timeout=0.1)\n\n# set key \"foo\" to value \"bar\"\nprint(r.set('foo', 'bar'))\n# set value for key \"foo\"\nprint(r.get('foo'))",
      "section_id": "connect-with-discovery-service"
    }
  ]
}
