{"record":{"id":"089d8f01d3f4b8b2","repo":"hyperledger/fabric","slug":"connection-to-s-terminated","errorCode":null,"errorMessage":"connection to %s terminated","messagePattern":"connection to (.+?) terminated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/runtime_launcher.go","lineNumber":95,"sourceCode":"\t\tstartFailCh = make(chan error, 1)\n\t\ttimeoutCh = time.NewTimer(r.StartupTimeout).C\n\n\t\tgo func() {\n\t\t\t// go through the build process to obtain connecion information\n\t\t\tccservinfo, err := r.Runtime.Build(ccid)\n\t\t\tif err != nil {\n\t\t\t\tstartFailCh <- errors.WithMessage(err, \"error building chaincode\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// chaincode server model indicated... proceed to connect to CC\n\t\t\tif ccservinfo != nil {\n\t\t\t\tif err = r.ConnectionHandler.Stream(ccid, ccservinfo, streamHandler); err != nil {\n\t\t\t\t\tstartFailCh <- errors.WithMessagef(err, \"connection to %s failed\", ccid)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlaunchState.Notify(errors.Errorf(\"connection to %s terminated\", ccid))\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// default peer-as-server model... compute connection information for CC callback\n\t\t\t// and proceed to launch chaincode\n\t\t\tccinfo, err := r.ChaincodeClientInfo(ccid)\n\t\t\tif err != nil {\n\t\t\t\tstartFailCh <- errors.WithMessage(err, \"could not get connection info\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ccinfo == nil {\n\t\t\t\tstartFailCh <- errors.New(\"could not get connection info\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err = r.Runtime.Start(ccid, ccinfo); err != nil {\n\t\t\t\tstartFailCh <- errors.WithMessage(err, \"error starting container\")\n\t\t\t\treturn\n\t\t\t}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/runtime_launcher.go#L77-L113","documentation":"During chaincode launch, the peer attempts a chaincode-as-a-server connection via ConnectionHandler.Stream. If the stream terminates without successful registration, the launcher notifies the launch state with this error. It means the external chaincode process dropped or closed the connection before completing registration.","triggerScenarios":"ConnectionHandler.Stream returns nil but the connection closes before the chaincode registers; the external chaincode service at ccid's address terminates the stream mid-handshake.","commonSituations":"External chaincode (chaincode-as-a-service) crashing or being killed at startup; wrong TLS certificates/mutual TLS config; chaincode listening on wrong port or address; network/firewall dropping long-lived connections between peer and chaincode pod (common in Kubernetes).","solutions":["Check the chaincode process logs for crashes or TLS handshake failures at startup","Verify CORE_CHAINCODE_ID_NAME matches the chaincode name:version and the chaincode is listening on the configured address","Check mutual TLS configuration on both peer and chaincode (core.yaml chaincode.externalBuilders / tls settings)","Ensure network connectivity (Kubernetes service/pod DNS, firewall rules) between peer and chaincode container","Retry the transaction; if transient, the chaincode may restart and register successfully"],"exampleFix":"// before: chaincode container with no keep-alive / wrong port\n// after: ensure chaincode serves on configured address\nenv: CORE_CHAINCODE_ID_NAME=\"mycc:1.0\"\n     CORE_CHAINCODE_ADDRESS=\"0.0.0.0:7052\"\n     CORE_CHAINCODE_TLS_ENABLED=true","handlingStrategy":"retry","validationCode":"// pre-check external chaincode reachability\nconn, err := net.DialTimeout(\"tcp\", ccAddress, 5*time.Second)\nif err != nil { return fmt.Errorf(\"chaincode %s not reachable at %s: %w\", ccid, ccAddress, err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"err := launcher.Launch(ccid).\nvar transientErr *peer.ErrChaincodeTerminated\nif errors.As(err, &transientErr) { /* retry launch after backoff */ }","preventionTips":["Use readiness probes so the peer only routes to healthy chaincode pods","Validate TLS certs before deployment on both peer and chaincode","Pin matching CORE_CHAINCODE_ID_NAME and address env vars","Monitor chaincode container restarts"],"tags":["chaincode","connection","network"],"backgroundTag":"chaincode-connection-terminated","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}