Connecting to TencentDB for Redis (over Public Network)

Last updated: 2020-12-16 11:43:15

    Operation Scenarios

    TencentDB for Redis does not support public network access for the time being. You can use a CVM instance with a public IP for port forwarding so as to access TencentDB for Redis over the public network.


    iptable-based forwarding may be unstable; therefore, you are not recommended to access instances over the public network in the production environment.


    1. Log in to the CVM instance and enable the CVM IP forwarding feature.


      The CVM and TencentDB instances must be under the same account and in the same VPC in the same region, or both in the classic network

      echo 1 > /proc/sys/net/ipv4/ip_forward
    2. Configure the forwarding rule. The sample code below forwards access requests originally to 26.xx.x.2:10001 (CVM instance public address with a custom port as desired) to the TencentDB for Redis instance with the private address
      iptables -t nat -A PREROUTING -p tcp --dport 10001 -j DNAT --to-destination
      iptables -t nat -A POSTROUTING -d -p tcp --dport 6379 -j MASQUERADE
    3. Configure the CVM security group to enable access to the public port of the CVM instance. You are recommended to open only source addresses that require access.
    4. On the accessing client, you can connect to the TencentDB for Redis instance on the private network simply by accessing the public IP 26.xx.xx.2:10001. The connection commands are the same as the private network connection commands. For more information, please see Instance Connection.
    5. After connecting to the TencentDB for Redis instance, run the info command. If the database information is returned, the connection is successful.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback