# 不可用：gRPC：连接被后端服务拒绝，地址 10.0.0.1:8080

- **ID:** `grpc/client-connection-refused`
- **领域:** grpc
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

gRPC 客户端尝试连接到后端服务的请求被拒绝，因为服务未在指定端口上监听或端口被防火墙阻止。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC v1.48.0 | active | — | — |
| gRPC v1.54.0 | active | — | — |
| gRPC v1.60.0 | active | — | — |
| Envoy 1.26.0 | active | — | — |

## 解决方案

1. ```
   验证后端服务是否正在运行并在预期端口上监听：在服务器上运行 `netstat -tulpn | grep 8080`。
   ```
2. ```
   检查防火墙规则以确保端口已开放：运行 `sudo ufw status` 或 `iptables -L -n`，如有需要添加规则：`sudo ufw allow 8080/tcp`。
   ```
3. ```
   更新客户端的目标 URI 以使用正确的主机或端口（如果配置错误），例如将 '10.0.0.1:8080' 更改为 '10.0.0.1:9090'。
   ```

## 无效尝试

- **** — Restarting the client application without checking the backend service status does not resolve the connection refusal. (60% 失败率)
- **** — Increasing gRPC retry intervals in the client config may delay the error but does not fix the underlying service unavailability. (50% 失败率)
- **** — Clearing the local DNS cache does not help because the error indicates a TCP connection refusal, not a resolution failure. (70% 失败率)
