All Products
Search
Document Center

Troubleshoot connection issues in ApsaraDB for Redis

Last Updated: Mar 29, 2022

Overview

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

Description

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

Use the internal endpoint of the ECS instance to access the ApsaraDB for Redis instance. For more information, see Redis-cli connection. 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 a local host, see Connect to the Internet.
  • We recommend that you use an Alibaba Cloud internal network to connect to an ApsaraDB for Redis instance over an ECS instance to improve security and reduce the impact of network duration on Redis performance.
  • If you cannot implement the following solutions due to conditions, you can create an ECS instance or an ApsaraDB for Redis instance in the same VPC.
Cause Solution
The ApsaraDB for Redis instance and the ECS instance do not belong to the same account.

According to the actual situation, select the corresponding solution:

The ECS instance and the ApsaraDB for Redis instance run in different regions. Create a new Redis instance in the region where the ECS is located, and then migrate data from the source Redis instance to the new instance. For more information, see Use redis-shake to migrate data in an RDB file.
The network types of ECS and Redis are different.
The security group rules of ECS block access to the internal endpoint and port of Redis. 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 Redis whitelist. For more information, see Configure an IP address whitelist.

Note: If the following error message appears, check the Redis whitelist settings. If the whitelist settings are correct and you can ping the ApsaraDB for Redis instance on the ECS instance, check the connection configurations in the application. For more information about how to ping an ApsaraDB for Redis instance, see Run the ping command to check the connection between ECS and ApsaraDB for Redis.

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

During DNS resolution, An error similar to the following is reported 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 connection address of the ApsaraDB for Redis instance and check the resolution. If the resolution fails, check whether the DNS configuration is correct. For more information, see Solution to the failure to connect to the ApsaraDB for Redis instance.
Abnormal behavior on the ECS instance triggers a security policy which disables ECS. If one of the ECS instances that are normally connected to ApsaraDB for Redis has a burst connection problem. In particular, if an ECS instance can be ping connected to an ApsaraDB for Redis instance, but the telnet command fails to test port 6379, the ECS may have abnormal behaviors (such as external attacks) that cause the service to be disabled. Check the server and set precise rules in the outbound direction of the security group. For example, the ECS can only access the IP address and port required by the service. This is the 6379 port of the ApsaraDB for Redis instance. For more information, see Add security group rules. If the problem cannot be resolved, submit a ticket.

Forgotten passwords

If you forget the Redis password, change the password in the ApsaraDB for Redis console. For more information, see Change the password.

Use client tools to connect to an 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 you fail to connect to ApsaraDB for Redis by using a client or redis-cli of each language, troubleshoot the connection between ApsaraDB for Redis and ECS instances.

Client Connection FAQ

Bandwidth restrictions cause connection failures

Each type of ApsaraDB for Redis instance has a bandwidth limit. For more information, see Query specifications. If your instance may encounter unexpected or scheduled traffic peaks, you can adjust the bandwidth of the instance. For more information, see Manually adjust the bandwidth of an instance.

  • If the engine version of the instance is 4.0 or later, find out the big Key and optimize it. For more information, see Offline full key analysis and Use the SCAN command.
  • 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.
  • Convert to a read /write splitting instance of the same specification to increase the bandwidth. For more information, see Change configurations. You can also store big Key or hotspot Key in read-only instances to avoid affecting other businesses.

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.
  • View monitoring metrics. For more information, see Monitoring metrics.
  • Query slow logs, and perform optimization based on slow log details. You can view slow logs in the Redis console or use SHOW LOG commands to view them. For more information, see View slow logs.
  • If the engine version of the instance is 4.0 or later, you can use the LazyFree mechanism to UNLINK, FLUSHALL ASYNC, FLUSHDB ASYNC commands, and related parameters to optimize your business code.
  • If the engine version of the instance is 4.0 or later, find out the big Key and optimize it. For more information, see Offline full key analysis and Use the SCAN command.

Applicable scope

  • ApsaraDB for Redis