All Products
Search
Document Center

Troubleshoot connection issues in ApsaraDB for Redis

Edit in GitHub
Last Updated: Apr 17, 2020 Edit in GitHub

Overview

This topic describes how to troubleshoot connection issues in ApsaraDB for Redis.

 

Description

If an exception occurs when you connect to ApsaraDB for Redis, you can troubleshoot the exception as stated in this topic.

 

Connection issues between an ApsaraDB for Redis instance and an ECS instance

To access an ApsaraDB for Redis instance from an ECS instance over the internal network, make sure that the ECS and ApsaraDB for Redis instances can be reached each other. If these instances cannot access each other, check the following possible causes:

Note: If these solutions are not available due to limited conditions, create a new ECS or ApsaraDB for Redis instance to make both instances in the same VPC.

  • The ApsaraDB for Redis and ECS instances do not belong to the same account. Solution:
  • The ECS and ApsaraDB for Redis instances are in different regions. Solution:
  • The ECS and ApsaraDB for Redis instances run in different types of networks: one in classic network and the other in VPC. Solution:
  • ECS security group rules deny access to the endpoint and port of the ApsaraDB for Redis instance. Solution:
    • Add security group rules to allow access to the endpoint and port of the ApsaraDB for Redis instance. For more information, see Add security group rules.
  • The whitelist of the ApsaraDB for Redis instance does not contain the private IP address of the ECS instance.
    • Set an ApsaraDB for Redis whitelist and add the private IP address of the ECS instance to it. For more information, see Set an IP whitelist.
      Note: If the "Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused" error message appears, check the whitelist of the ApsaraDB for Redis instance. If the private IP address of the ECS instance is in the whitelist and you are unable to ping the ApsaraDB for Redis instance from the ECS instance, check the connection configuration in the application.
  • During DNS resolution, the "UnknownHostException" or "failed to connect: r-***************.redis.rds.aliyuncs.com could not be resolved" error message appears on the client. Solution:
    • Run the ping or telnet command to test the DNS resolution for the ApsaraDB for Redis instance. If the resolution failed, check the DNS configuration.
  • Abnormal behavior on the ECS instance triggers a security policy which disables ECS. Multiple ECS instances normally connect to the ApsaraDB for Redis instance. Then, one of the ECS instance has a sudden connection issue. For example, the ECS instance can reach the ApsaraDB for Redis instance when you run the ping command, but the ECS instance fails to connect to port 6379 when you run the telnet command. In this case, the abnormal behavior such as outbound attacks on the ECS instance may cause ECS to be disabled. Solution:
    • Check the ECS instance and set precise outbound rules in a security group. For example, you can define that the ECS instance can only connect to the required IP address and port such as port 6379 of the ApsaraDB for Redis instance. If the issue persists, submit a ticket to request technical support.

 

Connect to ApsaraDB for Redis over the public network

To connect to apsaradb for Redis from a local host, seeInternet connection.

Note: We recommend that you connect to the ApsaraDB for Redis instance from an ECS instance over the Alibaba Cloud internal network for improved security and reduced network latency.

 

Forgotten passwords

If you forget the password used to connect to your ApsaraDB for Redis instance, change the password in the ApsaraDB for Redis console.

 

Client connection issues

You can use the following client connection methods:

  • Use Jedis, phpredis, redis-py, C or C++, .NET, Nodejs Redis, and C# clients to connect to an ApsaraDB for Redis instance. For more information, see Use a Redis client.
  • Use DMS to connect to and manage an ApsaraDB for Redis instance. For more information, see Use DMS.
  • Use the Redis command line interface (redis-cli) program to connect to and manage an ApsaraDB for Redis instance. For more information, see Use redis-cli.

Note: If you failed to connect to the ApsaraDB for Redis instance by using the clients or redis-cli, check connection issues between the ApsaraDB for Redis instance and the ECS instance.

 

Common client connection issues are as follows:

 

Bandwidth restrictions cause connection failures

Each ApsaraDB for Redis instance type has a maximum bandwidth. For more information, see Specifications and performance. If network resources are sufficient, ApsaraDB for Redis instances have unlimited bandwidth. However, if network resources are insufficient, the specified maximum bandwidth will take effect for the instances. When there is heavy network traffic, service requests are restricted by the maximum bandwidth.

  • Upgrade the instance configuration to increase the bandwidth efficiency.
  • Use a cluster instance of the same configuration to increase the bandwidth efficiency.
  • Use a read/write split instance of the same configuration to increase the bandwidth efficiency. You can also store large keys or hotkeys in read-only instances to avoid the interference with other services.

 

Poor or failed connections due to performance issues

Running the KEYS and HGETALL commands may affect the performance of ApsaraDB for Redis, and cause blocked threads and connection issues.

  • Do not run the KEYS, FLUSHALL, and FLUSHDB commands when the ApsaraDB for Redis instance is running in the production environment. For more information, see Disable high-risk commands.
  • Check monitoring metrics to identify possible causes and take the corresponding measures.
  • Query slow logs, and perform optimization based on slow log details. You can click Slow Logs in the ApsaraDB for Redis console or run the SHOW LOG command.
  • For Redis engine 4.0 or later, use the UNLINK, FLUSHALL ASYNC, and FLUSHDB ASYNC commands and related parameters in the Lazyfree feature to optimize service code.

 

Application scope

  • ApsaraDB for Redis