AWS ElastiCache Redis DNS error - Name or service not known The Problem &amp; The Question
I'm trying to create an AWS ElastiCache Redis-flavored cluster and connect to it from an instance in the same VPC. When I create the cluster initially, I can connect to it just fine via redis-cli. If I wait a day or two and then try to connect to it again via redis-cli, I get the following error:
$ redis-cli -h &lt;aws-elasticache-cluster-primary-endpoint&gt;
Could not connect to Redis at &lt;aws-elasticache-cluster-primary-endpoint&gt;:6379: Name or service not known
not connected&gt; 

I should be able to connect again with no issue. Why would I be getting DNS errors the next day when it worked initially? Nothing has changed about the cluster since I created it. How could I fix this?
Steps to Reproduce

ElastiCache Dashboard -&gt; Redis -&gt; Create.

Set the following options:




Option
Value




Cluster Engine
Redis


Location
Amazon Cloud


Engine version compatibility
6.x


Port
6379


Parameter group
default.redis6.x


Node type
cache.t3.micro


Number of replicas
0


Multi-AZ
false


Subnet group
default


Security groups
default


Encryption at-rest
false


Encryption in-transit
false




Create.

After creating, verify you can connect to the cluster with:
redis-cli -h &lt;aws-elasticache-cluster-primary-endpoint&gt;

Disconnect.

Try reconnecting with the same redis-cli command a few days later. You should see the errors shown in the section above.


Additional Information
nping
$ sudo nping --tcp -p 6379 &lt;aws-elasticache-cluster-primary-endpoint&gt;
Failed to resolve given hostname/IP: &lt;aws-elasticache-cluster-primary-endpoint&gt;.  Note that you can't use '/mask' AND '1-4,7,100-' style IP ranges
Cannot find a valid target. Please make sure the specified hosts are either IP addresses in standard notation or hostnames that can be resolved with DNS

nslookup
$ sudo nslookup &lt;aws-elasticache-cluster-primary-endpoint&gt;
Server:         75.75.75.75
Address:        75.75.75.75#53

** server can't find &lt;aws-elasticache-cluster-primary-endpoint&gt;: REFUSED

Reachability Analyzer
I followed AWS' instructions for testing connectivity from my EC2 instance to the ElastiCache cluster. The results I got back for the connectivity were:




Reachability Status
State




Reachable
Succeeded



Cluster Metrics




Metric
Value




CPU Utilization
~1.000%


Engine CPU Utilization
~0.283%


Database Memory Usage Percentage
~1.093%



Local Wireguard configuration
[Interface]
PrivateKey = &lt;value&gt;
ListenPort = 21841
Address = 10.0.0.2/32
DNS = 9.9.9.9 # 75.75.75.75 75.75.76.76

[Peer]
PublicKey = &lt;value&gt;
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = &lt;public-IP&gt;:51820
It could be due to a &quot;VPC DNS throttling&quot;, you can find more information on the official documentation.
https://aws.amazon.com/premiumsupport/knowledge-center/vpc-find-cause-of-failed-dns-queries/