go network_error ai_generated true

rpc error: code = Unavailable desc = all SubConns are in TransientFailure

ID: go/grpc-unavailable-load-balancer

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-08-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.21 active
1.22 active

Root Cause

The gRPC client's load balancer cannot connect to any backend server because all endpoints are unreachable or failing health checks.

generic

中文

gRPC客户端的负载均衡器无法连接到任何后端服务器,因为所有端点都不可达或健康检查失败。

Workarounds

  1. 85% success Verify server health and restart any down instances.
    // Check server status via health check endpoint
    healthClient := grpc_health_v1.NewHealthClient(conn)
    resp, err := healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{Service: "myservice.MyService"})
  2. 90% success Use a different load balancing policy like round_robin with proper service discovery.
    conn, _ := grpc.Dial("dns:///myservice:50051", grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`))

Dead Ends

Common approaches that don't work:

  1. Recreating the client without changing server addresses. 90% fail

    Same endpoints, same connectivity issue.

  2. Setting a shorter dial timeout. 80% fail

    Timeouts don't fix unreachable servers.