UNAVAILABLE api network_error ai_generated partial

gRPC错误:UNAVAILABLE。服务DNS解析失败:my-service.example.com:443

gRPC error: UNAVAILABLE. DNS resolution failed for service: my-service.example.com:443

ID: api/grpc-unavailable-dns-resolution

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
1证据数
2024-01-15首次发现

版本兼容性

版本状态引入弃用备注
gRPC v1.56.0 active — — —
Envoy proxy 1.27 active — — —
Kubernetes 1.28 active — — —

根因分析

gRPC客户端无法解析目标服务主机名,由于DNS配置问题或网络连接问题。

English

gRPC client cannot resolve the target service hostname due to DNS configuration issues or network connectivity problems.

generic

官方文档

https://grpc.github.io/grpc/core/md_doc_dns-resolver.html

解决方案

  1. Verify DNS resolution manually: run 'dig my-service.example.com' or 'nslookup my-service.example.com'. If it fails, check /etc/resolv.conf for valid nameservers (e.g., 8.8.8.8).
  2. Increase gRPC DNS resolver timeout: set GRPC_DNS_RESOLVER_TIMEOUT_MS=5000 environment variable before starting the client.
  3. If using Kubernetes, ensure the service DNS name matches the gRPC target (e.g., my-service.namespace.svc.cluster.local). Use 'kubectl run -it --rm debug --image=busybox -- nslookup my-service' to test.

无效尝试

常见但无效的做法:

  1. 75% 失败

    Restarting the gRPC client without fixing DNS configuration (e.g., missing /etc/resolv.conf entries) will reproduce the same error.

  2. 60% 失败

    Changing the target endpoint to an IP address bypasses DNS but may fail if the service uses virtual hosting or TLS SNI requires the hostname.