Connect to a Memorystore for Redis Cluster instance
Stay organized with collections
Save and categorize content based on your preferences.
This page explains how to connect to a Memorystore for Redis Cluster instance.
Client support
Memorystore for Redis Cluster does not provide its own client libraries, but rather
supports existing third-party client libraries that support the Redis protocol.
An example list of clients can be found on the Redis Clients
page.
Redis-py client best practice
To connect to your Memorystore for Redis Cluster instance using the redis-py Python client, you must add the skip_full_coverage_check=True when declaring a Redis
Cluster:
If you don't allowlist the correct ports on your firewall, your instance can
encounter connection errors. For more information about allowlisting ports, see
Troubleshoot issues.
Cross region access
You can access a Memorystore for Redis Cluster instance from a client located in a
different region than where the Memorystore instance is located.
View your cluster's discovery endpoint
To view your Memorystore cluster's discovery endpoint, use the following instructions:
Console
Go to the Memorystore for Redis Cluster page in the Google Cloud console.
In the Connect to this instance section, take a note of the IP address
and port number next to Discovery Endpoint. These two values used
together are your cluster's discovery endpoint.
gcloud
To view your cluster's discovery endpoint, run the describe
gcloud CLI as explained in the view instance details section.
Take a note of the endpoint address and port number listed in the
discovery_endpoints: section. These two values used together are your
cluster's discovery endpoint.
Connect from a Compute Engine VM using redis-cli
You can connect to the Memorystore for Redis Cluster instance from any
Compute Engine VM that uses the Memorystore instance's
authorized network.
To connect to the instance:
If you don't already have a Linux Compute Engine VM that uses the
authorized network for your Memorystore for Redis Cluster instance, create one and
connect to it by following Quickstart to create a Linux VM.
Install redis-cli version 6.0 or newer on the Compute Engine VM by
following the instructions at Install Redis on Linux.
DISCOVERY_ENDPOINT_ADDRESS and PORT_NUMBER
are the values you noted in the previous step.
Run the CLUSTER SHARDS command to view your cluster topology. Take a note
of one of the node's IP addresses and port numbers.
Connect to your desired node by running the following command:
redis-cli -h NODE_IP_ADDRESS -p NODE_PORT -c
Replace the following:
NODE_IP_ADDRESS is the node's IP address you found in the
previous step.
NODE_PORT is the node's port number you found in the previous
step.
Once connected to the node, enter some Redis commands:
Enter:
PING
Result:
PONG
Enter
SET HELLO WORLD
Result:
OK
Enter:
GET HELLO
Result:
"WORLD"
Once you are done testing your connection to the Redis node, you should
consider deleting the Compute Engine VM you used to connect to the
Redis instance. Doing so helps you avoid incurring charges to your
Cloud Billing account.
Connect to an in-transit encryption enabled instance
This section provides an example of how to connect to a Memorystore for Redis Cluster
instance that has in-transit encryption enabled.
If you don't already have a Compute Engine VM that uses the same
authorized network as the Redis instance from the previous step, create one
and connect to it by following Quickstart using a Linux VM.
Install redis-cli version 6.0 or newer on the Compute Engine VM
by following the instructions at Install Redis on Linux.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[],null,["# Connect to a Memorystore for Redis Cluster instance\n\nThis page explains how to connect to a Memorystore for Redis Cluster instance.\n\nClient support\n--------------\n\nMemorystore for Redis Cluster does not provide its own client libraries, but rather\nsupports existing third-party client libraries that support the Redis protocol.\nAn example list of clients can be found on the Redis [Clients](https://redis.io/docs/clients/)\npage.\n\n### Redis-py client best practice\n\nTo connect to your Memorystore for Redis Cluster instance using the [redis-py](https://github.com/redis/) Python client, you must add the `skip_full_coverage_check=True` when declaring a Redis\nCluster: \n\n from rediscluster import RedisCluster\n endpoints = [{\"host\": \"IPADDRESS\", \"port\": \"6379\"}]\n\n rdb = RedisCluster(\n startup_nodes=endpoints,\n skip_full_coverage_check=True, # Required for Memorystore\n decode_responses = True)\n\n print(rdb.set('PYTHON', 'CLUSTER'))\n print(rdb.get('PYTHON'))\n print(rdb.unlink('PYTHON'))\n\nAllowlist ports on firewall\n---------------------------\n\nIf you don't allowlist the correct ports on your firewall, your instance can\nencounter connection errors. For more information about allowlisting ports, see\n[Troubleshoot issues](/memorystore/docs/cluster/troubleshoot-issues#connection_error_caused_by_firewall_rules).\n\nCross region access\n-------------------\n\nYou can access a Memorystore for Redis Cluster instance from a client located in a\ndifferent region than where the Memorystore instance is located.\n\nView your cluster's discovery endpoint\n--------------------------------------\n\nTo view your Memorystore cluster's [discovery endpoint](/memorystore/docs/cluster/overview#discovery_endpoint), use the following instructions: \n\n### Console\n\n1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.\n\n [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters?)\n2. Click your Cluster ID.\n\n3. In the **Connect to this instance** section, take a note of the IP address\n and port number next to **Discovery Endpoint**. These two values used\n together are your cluster's discovery endpoint.\n\n### gcloud\n\nTo view your cluster's discovery endpoint, run the `describe`\ngcloud CLI as explained in the [view instance details](/memorystore/docs/cluster/create-manage-instances#view_instance_details) section.\n\nThe output should be similar to the following: \n\n authorizationMode: AUTH_MODE_DISABLED\n createTime: '2023-08-04T17:49:07.988918793Z'\n discoveryEndpoints:\n - address: 10.142.0.13\n port: 6379\n pscConfig:\n - network: projects/my-project-364018/global/networks/default\n name: projects/my-project-364018/locations/us-east1/clusters/my-cluster-1\n pscConnections:\n - address: 10.142.0.13\n forwardingRule: https://www.googleapis.com/compute/v1/projects/my-project-364018/regions/us-east1/forwardingRules/sca-auto-fr-5bc46f69-ec80-4c5a-8971-ce267a4d8ddd\n network: projects/my-project-364018/global/networks/default\n projectId: my-project-364018\n pscConnectionId: '25734306048376845'\n - address: 10.142.0.10\n forwardingRule: https://www.googleapis.com/compute/v1/projects/my-project-364018/regions/us-east1/.\n forwardingRules/sca-auto-fr-817b64c5-85ac-48d0-82e3-c6fa99b4e67d\n network: projects/my-project-364018/global/networks/default\n projectId: my-project-364018\n pscConnectionId: '25734306048376842'\n replicaCount: 0\n shardCount: 3\n sizeGb: 39\n state: ACTIVE\n tier: PERFORMANCE\n transitEncryptionMode: TRANSIT_ENCRYPTION_MODE_DISABLED\n uid: cddda5de-d91f-449b-8755-3a665430271a\n\nTake a note of the endpoint address and port number listed in the\n`discovery_endpoints:` section. These two values used together are your\ncluster's discovery endpoint.\n\nConnect from a Compute Engine VM using redis-cli\n------------------------------------------------\n\nYou can connect to the Memorystore for Redis Cluster instance from any\nCompute Engine VM that uses the Memorystore instance's\nauthorized network.\n\nTo connect to the instance:\n\n1. If you don't already have a Linux Compute Engine VM that uses the\n authorized network for your Memorystore for Redis Cluster instance, create one and\n connect to it by following [Quickstart to create a Linux VM](/compute/docs/create-linux-vm-instance).\n\n2. Install `redis-cli` version 6.0 or newer on the Compute Engine VM by\n following the instructions at [Install Redis on Linux](https://redis.io/docs/getting-started/installation/install-redis-on-linux/).\n\n3. [View your cluster's discovery endpoint](/memorystore/docs/cluster/connect-cluster-instance#view_your_clusters_discovery_endpoint)\n and make a note of it.\n\n4. Connect to your instance's discovery endpoint by running the following\n command:\n\n ```\n redis-cli -h DISCOVERY_ENDPOINT_ADDRESS -p PORT_NUMBER -c\n ```\n\n Where:\n - \u003cvar translate=\"no\"\u003eDISCOVERY_ENDPOINT_ADDRESS\u003c/var\u003e and \u003cvar translate=\"no\"\u003ePORT_NUMBER\u003c/var\u003e are the values you noted in the previous step.\n\n | **Note:** The `-c` switch is used to enable the `redis-cli` cluster support mode. If the `-c` switch is not provided, when you try to access keys from a different shard than the one you are connected to, it results in a `MOVED` error. In the cluster support mode the client is automatically reconnected to the address returned in the error response. For more details, see [Using Redis-CLI with a Redis Cluster](https://developer.redis.com/operate/redis-at-scale/scalability/redis-cli-with-redis-cluster/).\n5. Run the `CLUSTER SHARDS` command to view your cluster topology. Take a note\n of one of the node's IP addresses and port numbers.\n\n6. Connect to your desired node by running the following command:\n\n ```\n redis-cli -h NODE_IP_ADDRESS -p NODE_PORT -c\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eNODE_IP_ADDRESS\u003c/var\u003e is the node's IP address you found in the previous step.\n - \u003cvar translate=\"no\"\u003eNODE_PORT\u003c/var\u003e is the node's port number you found in the previous step.\n7. Once connected to the node, enter some Redis commands:\n\n Enter: \n\n ```\n PING\n ```\n\n Result: \n\n ```\n PONG\n ```\n\n Enter \n\n ```\n SET HELLO WORLD\n ```\n\n Result: \n\n ```\n OK\n ```\n\n Enter: \n\n ```\n GET HELLO\n ```\n\n Result: \n\n ```\n \"WORLD\"\n ```\n8. Once you are done testing your connection to the Redis node, you should\n consider deleting the Compute Engine VM you used to connect to the\n Redis instance. Doing so helps you avoid incurring charges to your\n Cloud Billing account.\n\nConnect to an in-transit encryption enabled instance\n----------------------------------------------------\n\nThis section provides an example of how to connect to a Memorystore for Redis Cluster\ninstance that has in-transit encryption enabled.\n\n1. If you don't already have a Compute Engine VM that uses the same\n authorized network as the Redis instance from the previous step, create one\n and connect to it by following [Quickstart using a Linux VM](/compute/docs/create-linux-vm-instance).\n\n 1. Install `redis-cli` version 6.0 or newer on the Compute Engine VM by following the instructions at [Install Redis on Linux](https://redis.io/docs/getting-started/installation/install-redis-on-linux/).\n2. Install your instance's certificate authority on the Linux VM by following\n the instructions at [Install certificate authorities on your client](https://cloud.google.com/memorystore/docs/cluster/manage-in-transit-encryption#install_certificate_authorities_on_your_client).\n\n3. [View your cluster's discovery endpoint](/memorystore/docs/cluster/connect-cluster-instance#view_your_clusters_discovery_endpoint)\n and make a note of it.\n\n4. Connect to your instance's discovery endpoint by running the following\n command:\n\n ```\n redis-cli -h DISCOVERY_ENDPOINT_ADDRESS -p PORT_NUMBER -c --tls --cacert /tmp/server_ca.pem\n ```\n\n Where:\n - \u003cvar translate=\"no\"\u003eDISCOVERY_ENDPOINT_ADDRESS\u003c/var\u003e and \u003cvar translate=\"no\"\u003ePORT_NUMBER\u003c/var\u003e are the values you noted in the previous step.\n\n | **Note:** The `-c` switch is used to enable the `redis-cli` cluster support mode. If the `-c` switch is not provided, when you try to access keys from a different shard than the one you are connected to, it results in a `MOVED` error. In the cluster support mode the client is automatically reconnected to the address returned in the error response. For more details, see [Using Redis-CLI with a Redis Cluster](https://developer.redis.com/operate/redis-at-scale/scalability/redis-cli-with-redis-cluster/).\n5. Run the `CLUSTER SHARDS` command to view your cluster topology. Take a note\n of one of the node's IP addresses and port numbers.\n\n6. Connect to your desired node by running the following command:\n\n ```\n redis-cli -h NODE_IP_ADDRESS -p NODE_PORT -c --tls --cacert /tmp/server_ca.pem\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eNODE_IP_ADDRESS\u003c/var\u003e is the node's IP address you found in the previous step.\n - \u003cvar translate=\"no\"\u003eNODE_PORT\u003c/var\u003e is the node's port number you found in the previous step.\n7. Once connected to the node, enter some Redis commands:\n\n Enter: \n\n ```\n PING\n ```\n\n Result: \n\n ```\n PONG\n ```"]]