# UNAVAILABLE: DNS 解析器：查询 _grpc._tcp.example.com 的 DNS SRV 记录失败：查找 _grpc._tcp.example.com：没有此主机

- **ID:** `grpc/name-resolver-failure-dns`
- **领域:** grpc
- **类别:** network_error
- **错误码:** `GRPC_DNS_SRV_LOOKUP_FAILED`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

gRPC 的 DNS 解析器尝试解析服务的 SRV 记录，但 DNS 服务器返回 NXDOMAIN，因为 SRV 记录缺失或配置错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC-go v1.62.0 | active | — | — |
| gRPC-java v1.61.0 | active | — | — |
| C-core v1.62.0 | active | — | — |

## 解决方案

1. ```
   Add the missing SRV record in DNS: _grpc._tcp.example.com. 3600 IN SRV 0 0 50051 server1.example.com. Also ensure A/AAAA records exist for server1.example.com.
   ```
2. ```
   Use the 'passthrough' resolver to bypass SRV lookup: set target URI to 'passthrough:///server1.example.com:50051' which resolves using standard A/AAAA records only.
   ```
3. ```
   Configure a custom resolver in code: in Go, implement resolver.Builder and register it with resolver.Register(myBuilder) to provide a static list of addresses.
   ```

## 无效尝试

- **** — Adding a fallback to IP address in the target URI (e.g., dns:///192.168.1.1:50051) bypasses service discovery entirely, breaking load balancing and failover. (90% 失败率)
- **** — Disabling DNS resolution with grpc.lb_policy=round_robin does not fix the missing SRV record; the resolver still fails before load balancing starts. (85% 失败率)
