go network_error ai_generated true

rpc error: code = Unavailable desc = name resolver error: failed to query DNS: lookup myservice.example.com: no such host

ID: go/grpc-unavailable-dns-resolution-failed

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2025-04-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.0 active
1.1 active

Root Cause

The DNS name used in the gRPC target cannot be resolved, often due to incorrect hostname or DNS misconfiguration.

generic

中文

gRPC目标中使用的DNS名称无法解析,通常是由于主机名错误或DNS配置错误。

Workarounds

  1. 95% success Verify the DNS record and correct the hostname.
    Use nslookup or dig to check: nslookup myservice.example.com. Update the target address accordingly.
  2. 90% success Use an IP address directly instead of a hostname.
    conn, err := grpc.Dial("10.0.0.1:8080", grpc.WithInsecure())

Dead Ends

Common approaches that don't work:

  1. Use a random IP address hoping it resolves. 100% fail

    The client specifically tries to resolve the given name; random IPs are ignored.

  2. Ignore the error and retry indefinitely. 100% fail

    Without DNS resolution, the connection will never succeed.