# rpc error: code = Unavailable desc = grpc: the client connection is closing

- **ID:** `go/grpc-client-conn-closed`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The *grpc.ClientConn was closed (conn.Close()) while an RPC was in flight, or Close was called on a shared conn during shutdown while other goroutines still use it.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   var conn *grpc.ClientConn
func Init() error {
  var err error
  conn, err = grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
  return err
}
// Close only at shutdown via signal handler
   ```
2. **** (88% success)
   ```
   var wg sync.WaitGroup
wg.Add(1)
go func() { defer wg.Done(); client.Do(ctx, req) }()
wg.Wait()
conn.Close()
   ```

## Dead Ends

- **** — Closes the shared connection after the first call; subsequent calls fail. (90% fail)
- **** — A closed ClientConn cannot be reused; all calls fail immediately. (95% fail)
