All Products
Search
Document Center

Troubleshoot connection issues in ApsaraDB for Redis

Last Updated: Dec 16, 2020

Introduction

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

Background

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

Connect an ECS instance to an apsaradb for Redis instance over the internal network. For more information about how to connect redis cli to an ECS instance, see connect the ECS instance to the apsaradb for Redis instance. If these instances cannot access each other, check the following possible causes:

Note:

  • For more information about how to connect to an apsaradb for Redis instance from an on-premises server, see connect to apsaradb for Redis over the Internet.
  • We recommend that you connect the ECS instance to the apsaradb for Redis instance over an internal network of Alibaba Cloud to improve security and reduce network latency.
  • If the following 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.
Possible cause Fixes
The ApsaraDB for Redis instance and the ECS instance do not belong to the same account.
The ECS instance and the ApsaraDB for Redis instance run in different regions.

Create a new apsaradb for Redis instance in the region where the ECS instance is located, and then migrate the data from the source apsaradb for Redis instance to the new instance. For more information, see use redis-shake to migrate data from an RDB file.

The ECS instance and the apsaradb for Redis instance run in different types of networks.
ECS Security group rules deny access to the internal IP address and port of the apsaradb for Redis instance.

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.

Add the internal IP address of the ECS instance to the apsaradb for Redis whitelist. For more information, see set an IP whitelist.

Note: if the following error occurs, check the whitelist settings of the apsaradb for Redis instance. If the whitelist settings are correct and the apsaradb for Redis instance can be pinged from the ECS instance, check the connection configuration in the application. For more information about how to test the connection between an ECS instance and an apsaradb for Redis instance by using ping messages, see use the ping command to check the connection between an ECS instance and an apsaradb for Redis instance.

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused

During DNS resolution, An error similar to the following occurs on the client:

  • UnknownHostException
  • failed to connect: r-***************.redis.rds.aliyuncs.com could not be resolved

Run the ping or telnet command to test the DNS resolution for the apsaradb for Redis instance. If the resolution failed, check whether the DNS settings are correct.

Abnormal behavior on the ECS instance triggers a security policy which disables ECS. If multiple ECS instances normally connect to the apsaradb for Redis instance, one of them has a sudden connection issue. If an ECS instance can ping the Redis instance but you fail to run the telnet command on port 6379, the service may be disabled due to abnormal behavior on the ECS instance, such as outbound attacks.

Check the ECS instance and set precise outbound rules in a security group. For example, you can define that the ECS instance can only access the required IP address and port, which is Port 6379 of the apsaradb for Redis instance. For more information, see add security group rules. If the problem persists, submit a ticket for detailed troubleshooting.

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.

Connect to an AnalyticDB for PostgreSQL instance

Connect clients to an ApsaraDB for Redis instance

  • 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 the connection to the apsaradb for Redis instance fails when you use clients or redis-cli of different languages, check connection issues between the apsaradb for Redis instance and the ECS instance.

FAQ about client connections

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. For more information, see change configurations.
  • Use a cluster instance of the same configuration to increase the bandwidth efficiency. For more information, see change configurations.
  • Use an read /write splitting instance of the same configuration to increase the bandwidth efficiency. For more information, see change specifications. Also, large keys or hotkeys can be stored in read-only instances to avoid affecting 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 LOG on to the apsaradb for Redis console to view slow LOG or use SHOW LOG commands to view the directories of the For more information about the errors, see view slow LOG.
  • If the engine version of your instance is 4.0 or later, use the UNLINK, flushhallasync, and FLUSHDBASYNC commands and related parameters in the LazyFree feature to optimize service code.
  • If the engine version of the instance is 4.0 or above, find out of big keys is used to optimize. If the engine version of an apsaradb for Redis instance is earlier than 4.0, you can find large analyzing the memory structure and optimize them by using the SCAN command or keys.

Application scope

  • ApsaraDB for Redis