ECS Service Connect: DNS resolution failed for service endpoint within the same namespace
ID: cloud/aws-ecs-service-connect-dns-resolution-failure
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| AWS ECS: latest | active | — | — | — |
| AWS Cloud Map: latest | active | — | — | — |
| Amazon VPC: any | active | — | — | — |
Root Cause
When using ECS Service Connect, tasks fail to resolve the DNS name of a service in the same namespace because the service discovery namespace is not properly associated with the VPC, or the service's DNS records are not propagated due to a misconfigured service connect configuration.
generic中文
使用 ECS Service Connect 时,任务无法解析同一命名空间中服务的 DNS 名称,因为服务发现命名空间未正确关联到 VPC,或者由于服务连接配置错误导致服务的 DNS 记录未传播。
Official Documentation
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect.htmlWorkarounds
-
85% success Verify that the Cloud Map namespace is associated with the correct VPC. Run 'aws servicediscovery list-namespaces' and check the VPC configuration. If missing, create a new namespace with 'aws servicediscovery create-http-namespace --name my-namespace --vpc vpc-12345'.
Verify that the Cloud Map namespace is associated with the correct VPC. Run 'aws servicediscovery list-namespaces' and check the VPC configuration. If missing, create a new namespace with 'aws servicediscovery create-http-namespace --name my-namespace --vpc vpc-12345'.
-
80% success Ensure the ECS task definition includes the 'awslogs' log driver and check the Service Connect logs for DNS queries using 'aws logs describe-log-groups' and filtering for 'DNS_RESOLUTION_FAILED'. Then update the service connect configuration with the correct 'clientAlias' and 'discoveryName'.
Ensure the ECS task definition includes the 'awslogs' log driver and check the Service Connect logs for DNS queries using 'aws logs describe-log-groups' and filtering for 'DNS_RESOLUTION_FAILED'. Then update the service connect configuration with the correct 'clientAlias' and 'discoveryName'.
中文步骤
Verify that the Cloud Map namespace is associated with the correct VPC. Run 'aws servicediscovery list-namespaces' and check the VPC configuration. If missing, create a new namespace with 'aws servicediscovery create-http-namespace --name my-namespace --vpc vpc-12345'.
Ensure the ECS task definition includes the 'awslogs' log driver and check the Service Connect logs for DNS queries using 'aws logs describe-log-groups' and filtering for 'DNS_RESOLUTION_FAILED'. Then update the service connect configuration with the correct 'clientAlias' and 'discoveryName'.
Dead Ends
Common approaches that don't work:
-
80% fail
Overrides the default AWS DNS resolver, breaking Service Connect's built-in DNS resolution for the namespace.
-
70% fail
IPs can change when tasks are redeployed or scaled; defeats the purpose of service discovery.
-
50% fail
Restarting doesn't fix the underlying DNS configuration issue; the new tasks will face the same resolution failure.