# rpc错误：代码=不可用 描述=连接错误：拨号tcp：在127.0.0.11:53上查找主机：无此主机

- **ID:** `go/grpc-unavailable-connection-error`
- **领域:** go
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

目标gRPC服务器主机名的DNS解析失败，通常是由于DNS配置错误或客户端连接字符串中的主机名不正确。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.22 | active | — | — |
| 1.23 | active | — | — |

## 解决方案

1. **Use IP address instead of hostname in the gRPC target.** (90% 成功率)
   ```
   conn, err := grpc.Dial("192.168.1.100:50051", grpc.WithInsecure())
   ```
2. **Configure custom DNS resolver in Go net package.** (85% 成功率)
   ```
   net.DefaultResolver = &net.Resolver{PreferGo: true, Dial: func(ctx context.Context, network, address string) (net.Conn, error) { d := net.Dialer{}; return d.DialContext(ctx, "udp", "8.8.8.8:53") }}
   ```

## 无效尝试

- **Retrying the same connection with backoff but not fixing DNS.** — DNS resolution remains broken; retries never succeed. (95% 失败率)
- **Changing port number in the dial string.** — The issue is hostname resolution, not port; changing port doesn't help. (98% 失败率)
