If an ECS instance fails to resolve the endpoint of a Tair (or Redis open-source edition) instance due to a DNS service issue, the network connection between the ECS and Tair instances is interrupted. You can refer to this article to resolve such issues.
Causes
Connection issues between an ECS instance and a Tair instance can occur for various reasons. The following error messages indicate a hostname or endpoint resolution failure. If you encounter one, check your domain name and DNS server settings.
-
Name or service not known -
UnknownHostException -
failed to connect: r-***************.redis.rds.aliyuncs.com could not be resolved
Procedure
The following steps use a Linux environment as an example.
-
Verify that the Tair endpoint configured in your application code is correct.
NoteThe endpoint for your Tair instance is located in the Endpoint section on the instance details page in the Tair console.
Figure 1. View endpoints: The connection information includes the network type (VPC and public access), connection type (direct connection endpoint and proxy mode endpoint), the endpoint (for example,
r-8vb***.redis.zhangbei.rds.aliyuncs.com), and the port number (the default is6379). Always use the endpoint to connect to the instance, because its underlying IP address can change during maintenance. -
Ensure that the ECS instance is configured with the correct DNS server. For detailed instructions, see What do I do if a Linux instance fails to resolve domain names?.
-
Optional: If the preceding steps do not resolve the issue, you can use a temporary workaround.
Add the IP address mapping for the Tair instance's domain name to the
/etc/hostsfile. Then, refer to the Tair connection troubleshooting workflow document to rule out other potential causes.ImportantBe cautious when editing system files such as
/etc/hostsorresolv.conf. This modification to/etc/hostsis a temporary solution and will fail if the IP address of the Tair instance changes.