Connect to a Redis cluster
You can connect to a Redis cluster:
- via Docker;
- program code with SSL and without SSL.
Connecting with an SSL certificate is available for all methods.
When connecting, specify the port and address.
Connection ports
Use the following ports to connect to Redis:
- 6380 — port for connecting with an SSL certificate;
- 6379 — port for connecting without an SSL certificate (only available for clusters in a private subnet).
Connection addresses
You can select a connection address based on one of the following scenarios:
- connecting to a cluster in a public subnet;
- connecting from a private subnet to a cluster in a private subnet;
- connecting from the Internet to a cluster in a private subnet.
You can view the connection address in the Control Panel.

Connecting to a cluster in a public subnet
If the cluster is in a public subnet, you can connect to the nodes using a DNS address or an IP address from the public subnet.
We recommend connecting via a DNS address. The cluster uses the master discovery mechanism for DNS addresses: the address is bound to the node role rather than the node itself. If the master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.
When connecting via an IP address from a public subnet, the master discovery mechanism is not used. If one of the replicas becomes the new master, the master's IP address will change, and the connection using the old IP address will stop working.
Connecting from a private subnet to a cluster in a private subnet
If you are connecting from a private subnet to a cluster in a private subnet, you can use a DNS address or a private IP address.
We recommend connecting via a DNS address. The cluster uses the master discovery mechanism for DNS addresses: the address is bound to the node role rather than the node itself. If the master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.
When connecting via a private IP address, the master discovery mechanism is not used. If one of the replicas becomes the new master, the master's IP address will change, and the connection using the old IP address will stop working.
To connect from another private subnet, first connect both private subnets to a cloud router.
Connecting from the Internet to a cluster in a private subnet
If you connect to a cluster in a private subnet from the internet, you can only use a public floating IP address (Floating IP).
For public floating IP addresses (Floating IPs), the master discovery mechanism is used — the address is bound to the node's role, not to the node itself. If the master becomes unavailable, one of the replicas becomes the new master, and the address moves to the new node along with the role.
View the connection address
- In the Control panel, in the top menu, click Products and select Cloud Databases.
- Open the Active tab.
- Go to the database cluster page → Connection tab.
- In the Connection addresses block, check the address.
Connect via SSL
Connecting using TLS(SSL) encryption ensures a secure connection between your server and the database cluster.
Bash
PowerShell
Python
PHP
Go
Node.js
-
Download the root certificate and place it in the
~/.redis/:folder:mkdir -p ~/.redis/wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.redis/root.crtchmod 600 ~/.redis/root.crt -
Connect to the cluster:
redis-cli -h <host> \-a <password> \-p <port> \--tls \--cacert ~/.redis/root.crtSpecify:
<host>— DNS address or public floating IP address of the node;<password>— the password;<port>— the connection port.
Connect without SSL
Connection without SSL is only available for clusters in a private subnet.
Bash
PowerShell
Python
PHP
Go
Node.js
-
Open the CLI.
-
Connect to the cluster:
redis-cli -h <host> \-a <password> \-p <port>Specify:
<host>— DNS address or public floating IP address of the node;<password>— the password;<port>— connection port.
Connect via Docker
-
Download the root certificate and place it in the
~/.redis/:folder:mkdir -p ~/.redis/wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.redis/root.crtchmod 600 ~/.redis/root.crt -
Connect to the cluster:
docker run --rm -it \-v $(pwd)/.redis/root.crt:/root.crt \redis \redis-cli \-h <host> \-a <password> \-p <port> --tls \--cacert /root.crtSpecify:
<host>— DNS address or public floating IP address of the node;<password>— the user password;<port>— connection port.