go
network_error
ai_generated
true
rpc error: code = Unavailable desc = failed to resolve service name: no such host
ID: go/grpc-unavailable-dns-resolution
80%Fix Rate
85%Confidence
0Evidence
2024-09-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.56.x | active | — | — | — |
| 1.57.x | active | — | — | — |
Root Cause
DNS resolution fails because the target hostname does not exist or DNS server is unreachable.
generic中文
DNS 解析失败,因为目标主机名不存在或 DNS 服务器不可达。
Workarounds
-
85% success
resolver := &customResolver{}; conn, err := grpc.Dial("dns:///service.example.com:50051", grpc.WithResolvers(resolver)) -
90% success
nslookup service.example.com; verify /etc/resolv.conf
-
80% success
conn, err := grpc.Dial("127.0.0.1:50051", grpc.WithInsecure())
Dead Ends
Common approaches that don't work:
-
Hardcoding an IP address instead of hostname.
60% fail
IP may change, causing future failures.
-
Retrying indefinitely without fixing DNS.
90% fail
DNS issue persists.
-
Modifying system DNS settings.
50% fail
May not be applicable in containerized environments.