{"record":{"id":"6527088b7edf1eeb","repo":"netbirdio/netbird","slug":"no-connection-to-management","errorCode":null,"errorMessage":"no connection to management","messagePattern":"no connection to management","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/management/client/grpc.go","lineNumber":488,"sourceCode":"\t\tlog.Debugf(\"got an update message from Management Service\")\n\t\tdecryptedResp := &proto.SyncResponse{}\n\t\terr = encryption.DecryptMessage(serverPubKey, c.key, update.Body, decryptedResp)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"failed decrypting update message from Management Service: %s\", err)\n\t\t\treturn err\n\t\t}\n\n\t\tif err := msgHandler(decryptedResp); err != nil {\n\t\t\tlog.Errorf(\"failed handling an update message received from Management Service: %v\", err.Error())\n\t\t}\n\t}\n}\n\n// HealthCheck actively probes the management server and returns an error if unreachable.\n// Used to validate connectivity before committing configuration changes.\nfunc (c *GrpcClient) HealthCheck() error {\n\tif !c.ready() {\n\t\treturn errors.New(errMsgNoMgmtConnection)\n\t}\n\n\t_, err := c.getServerPublicKey()\n\treturn err\n}\n\n// getServerPublicKey fetches the server's WireGuard public key.\nfunc (c *GrpcClient) getServerPublicKey() (*wgtypes.Key, error) {\n\tmgmCtx, cancel := context.WithTimeout(c.ctx, 5*time.Second)\n\tdefer cancel()\n\tresp, err := c.realClient.GetServerKey(mgmCtx, &proto.Empty{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed getting Management Service public key: %w\", err)\n\t}\n\n\tserverKey, err := wgtypes.ParseKey(resp.Key)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/shared/management/client/grpc.go#L470-L506","documentation":"Returned by GrpcClient.HealthCheck (shared/management/client/grpc.go:488): the method first checks c.ready(), which requires the underlying gRPC connection state to be Ready or Idle (grpc.go:183-185). If the transport is in TransientFailure, Connecting, or Shutdown, the probe is skipped and this error is returned before any RPC goes out.","triggerScenarios":"Calling HealthCheck before a successful client.Connect, after the connection has dropped (server down, network change, TLS failure), or after Stop() closed the client. Distinguished from a probe failure: here the client already knows it has no usable transport.","commonSituations":"Using the client in code that skips the Connect error; management service restarting while the agent polls; misconfigured management URL or port so the connection never became ready; firewall blocking gRPC.","solutions":["Ensure you created the client via NewClient and the initial Connect/Login succeeded before calling HealthCheck","Check the management service is reachable (correct host:port, TLS setup) and restart or re-dial the connection, then retry the health check","Treat this error as 'not connected' rather than 'server unhealthy': reconnect instead of probing"],"exampleFix":"// before\nclient, _ := client.NewClient(ctx, mgmAddr, nil)\nerr := client.HealthCheck() // no connection to management\n\n// after\nclient, err := client.NewClient(ctx, mgmAddr, nil)\nif err != nil { return err }\nif err := client.Connect(ctx, ...); err != nil { return err } // establish transport first\nerr = client.HealthCheck()","handlingStrategy":"retry","validationCode":"// Use the non-probing status check first\nif !client.IsHealthy() { // never returns this error; checks conn state + IsHealthy RPC\n    // reconnect before probing\n}","typeGuard":null,"tryCatchPattern":"err := client.HealthCheck()\nif err != nil {\n    if strings.Contains(err.Error(), \"no connection to management\") {\n        // transport is down: reconnect (Connect/backoff), then retry once ready;\n        // do not treat this specific error as 'server unhealthy'\n    }\n    return err\n}","preventionTips":["Always handle the error returned by client creation/Connect before using the client","Prefer IsHealthy() for background monitoring and reserve HealthCheck() for pre-commit validation of an established connection","Retry with backoff around reconnect+healthcheck when management restarts"],"tags":["go","grpc","netbird","client","connectivity"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}