Skip to main content
Connect to a Redis cluster

Connect to a Redis cluster

You can connect to a Redis cloud database cluster by DNS address, private IP address, and public IP address.

We recommend connecting by DNS address because DNS addresses correspond to node roles and lead to the actual IP addresses of the master and replicas. IP addresses correspond to specific nodes. If the master is unavailable, one of the replicas will assume its role, the master's IP address will change, and the IP connection will stop working.

If the cluster is connected to a private subnet and you want to work with it via DNS, connect the cluster subnet to a cloud router with access to the external network. Use the following instructions Set up internet access via cloud router.

If the cluster is connected to a private network and you need to configure access to the node from the Internet, connect a public IP address.

Ports

Use ports to connect to Redis:

  • 6380 — port for connection with SSL certificate;
  • 6379 — port for connection without SSL certificate (available only for clusters in private subnet).

Ways of connection

Connection with SSL certificate is available for all methods.

View the address for connection

  1. В control panels go to Cloud platformDatabases.
  2. Open the Database Cluster page → tab Connection.
  3. In the block Addresses for connection check out the address.

Connect with SSL

Connecting using TLS/SSL encryption provides a secure connection between your server and the database cluster.

  1. Download the root certificate and place it in the folder ~/.redis/:

    mkdir -p ~/.redis/
    wget https://storage.dbaas.servercore.com/CA.pem -O ~/.redis/root.crt
    chmod 600 ~/.redis/root.crt
  2. Connect to the cluster:

    redis-cli -h <host> \
    -a <password> \
    -p 6380 \
    --tls \
    --cacert ~/.redis/root.crt

    Specify:

    • <host> — DNS address of the node;
    • <password> — password.

Connect without SSL

Connection without SSL is only available for clusters on a private subnet.

  1. Open the CLI.

  2. Connect to the cluster:

    redis-cli -h <host> \
    -a <password> \
    -p 6379

    Specify:

    • <host> — DNS address of the node;
    • <password> — password.

Connect from Docker

  1. Download the root certificate and place it in the folder ~/.redis/:

    mkdir -p ~/.redis/
    wget https://storage.dbaas.servercore.com/CA.pem -O ~/.redis/root.crt
    chmod 600 ~/.redis/root.crt
  2. Connect to the cluster:

    docker run --rm -it \
    -v $(pwd)/.redis/root.crt:/root.crt \
    redis \
    redis-cli \
    -h <host> \
    -a <password> \
    -p 6380 --tls \
    --cacert /root.crt

    Specify:

    • <host> — DNS address of the node;
    • <password> — user password.