go
runtime_error
ai_generated
true
rpc error: code = Unavailable desc = grpc: the server has been stopped
ID: go/grpc-server-stopped
80%Fix Rate
87%Confidence
0Evidence
2024-07-02First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| google.golang.org/grpc 1.50+ | active | — | — | — |
Root Cause
A call was made against a grpc.Server after GracefulStop()/Stop() completed, or before Serve() started.
generic中文
在 grpc.Server 的 GracefulStop()/Stop() 完成后,或在 Serve() 启动前发起了调用。
Workarounds
-
92% success
Order shutdown correctly: // on SIGTERM srv.GracefulStop() // stops accepting, drains in-flight lis.Close() // construct a fresh server on restart
-
88% success
Guard server lifecycle with sync.Once and a ready channel; only issue calls after Serve() has started (use a health check).
Dead Ends
Common approaches that don't work:
-
95% fail
grpc.Server cannot be restarted after Stop; you must construct a new one.
-
80% fail
Hides a lifecycle bug where the server is being used after shutdown.