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.
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.
- Check whether the endpoint of the ApsaraDB for Redis instance in the service code
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.
- 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?
- Optional:If the preceding procedure cannot solve your issue, you can use the following temporary
Add the domain name and IP address of the ApsaraDB for Redis instance to the
/etc/hostsfile 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/hostsfile in a similar manner as you edit the
resolv.conffile. This method serves only as a temporary solution. If the IP address of the ApsaraDB for Redis instance changes, this solution becomes invalid.