go
network_error
ai_generated
true
rpc error: code = Unavailable desc = 最后一次连接错误:连接错误:拨号 tcp: 在 10.0.0.2:53 上查找 grpc.example.com:没有该主机
rpc error: code = Unavailable desc = last connection error: connection error: desc = "transport: Error while dialing: dial tcp: lookup grpc.example.com on 10.0.0.2:53: no such host"
ID: go/grpc-unavailable-subchannel-transient-failure
80%修复率
87%置信度
0证据数
2025-03-04首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.30+ | active | — | — | — |
根因分析
gRPC 目标的 DNS 解析失败。常见于 Kubernetes 中服务名错误、DNS 服务器不可达,或 Pod 的 resolv.conf 配置错误时。
English
DNS resolution failed for the gRPC target. Common in Kubernetes when the service name is wrong, the DNS server is unreachable, or the pod's resolv.conf is misconfigured.
解决方案
-
92% 成功率
// Use <service>.<namespace>.svc.cluster.local conn, _ := grpc.Dial("users.default.svc.cluster.local:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) -
88% 成功率
conn, _ := grpc.Dial("dns:///users.default.svc.cluster.local:50051", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(`{"loadBalancingConfig":[{"round_robin":{}}]}`))
无效尝试
常见但无效的做法:
-
75% 失败
Breaks when the backend pod is rescheduled; loses load balancing across replicas
-
90% 失败
DNS NXDOMAIN returns immediately; a longer timeout does not make the name resolve