{
  "id": "test-client-connectivity",
  "title": "Test client connection",
  "url": "https://redis.io/docs/latest/operate/rs/7.8/databases/connect/test-client-connectivity/",
  "summary": "",
  "content": "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](), 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 \u003e General** section in the Cluster Manager UI:\n\n    \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]().\n\nIf any issues occur when testing database connections, [contact\nsupport](https://redis.com/company/support/).\n\n## Test database connections\n\nAfter you create a Redis database, you can connect to your\ndatabase and store data using one of the following methods:\n\n- [`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]() to view all Redis clients by language.\n\n### Connect with redis-cli\n\nConnect to your database with `redis-cli` (located in the `/opt/redislabs/bin` directory), then store and retrieve a key:\n\n```sh\n$ redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e\n127.0.0.1:16653\u003e set key1 123\nOK\n127.0.0.1:16653\u003e get key1\n\"123\"\n```\n\nFor more `redis-cli` connection examples, see the [`redis-cli` reference]().\n\n### Connect with Redis Insight\n\nRedis Insight is a free Redis GUI that is available for macOS, Windows, and Linux.\n\n1. [Install Redis 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]() is set up.\n\n1. Select **Add Redis Database** to connect to the database.\n\nSee the [Redis Insight documentation]() for more information.\n\n### Connect with Python\n\nPython 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    ```sh\n    vi redis_test.py\n    ```\n\n1. Paste the following code in `redis_test.py`, and replace `\u003chost\u003e` and `\u003cport\u003e` with your database's endpoint details:\n\n    ```python\n    import redis\n\n    # Connect to the database\n    r = redis.Redis(host='\u003chost\u003e', port=\u003cport\u003e)\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'))\n    ```\n\n1. Run the application:\n\n    ```sh\n    python redis_test.py\n    ```\n\n1. If the application successfully connects to your database, it outputs: \n\n    ```sh\n    set key1 123\n    True\n    get key1\n    123\n    ```\n### Connect with discovery service\n\nYou 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```python\nfrom 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'))\n```\n\nFor more `redis-py` connection examples, see the [`redis-py` developer documentation](https://redis.readthedocs.io/en/stable/examples/connection_examples.html).\n",
  "tags": ["docs","operate","rs"],
  "last_updated": "2026-04-01T08:10:08-05:00"
}

