If the endpoint of an ApsaraDB for Redis instance fails to be resolved when you use the endpoint to connect to the instance from an Elastic Compute Service (ECS) instance. The ECS instance fails to connect to the ApsaraDB for Redis instance. This topic describes how to troubleshoot this issue.


Various reasons may lead to connection issues between an ECS instance and an ApsaraDB for Redis instance. Failed DNS resolution is a common cause.

When the UnknownHostException or failed to connect: r-***************.redis.rds.aliyuncs.com could not be resolved error occurs, the host name is unknown or the resolution of the endpoint fails. Check whether the domain name and DNS server settings are correct.


In this example, the Linux operating system is used.

  1. Check whether the endpoint of the ApsaraDB for Redis instance in the service code is correct.
    Note You can view the endpoint of an ApsaraDB for Redis instance in the Endpoint section of the Instance Information page in the ApsaraDB for Redis console, as shown in the following figure.
    Figure 1. View endpoints
    View endpoints
  2. Check whether the DNS server is correctly configured in the ECS instance. For more information, see What do I do if a Linux instance fails to resolve domain names?
  3. Optional:If the preceding procedure cannot solve your issue, you can use the following temporary solution:
    Add the domain name and IP address of the ApsaraDB for Redis instance to the /etc/hosts file to ensure that the domain name can be resolved normally. For more information about other causes of connection issues, see Troubleshooting for connection issues in ApsaraDB for Redis.
    Important You can edit the /etc/hosts file in a similar manner as you edit the resolv.conf file. This method serves only as a temporary solution. If the IP address of the ApsaraDB for Redis instance changes, this solution becomes invalid.