hyperledger/fabric · error
query failed with status: %d - %s
Error message
query failed with status: %d - %s
What it means
Query checks the endorsement status; anything other than cb.Status_SUCCESS (200) produces this error carrying the peer's status code and message. The _lifecycle QueryInstalledChaincodes invocation was rejected or failed on the peer side.
Source
Thrown at internal/peer/lifecycle/chaincode/queryinstalled.go:127
if err != nil {
return errors.WithMessage(err, "failed to create signed proposal")
}
proposalResponse, err := i.EndorserClient.ProcessProposal(context.Background(), signedProposal)
if err != nil {
return errors.WithMessage(err, "failed to endorse proposal")
}
if proposalResponse == nil {
return errors.New("received nil proposal response")
}
if proposalResponse.Response == nil {
return errors.New("received proposal response with nil response")
}
if proposalResponse.Response.Status != int32(cb.Status_SUCCESS) {
return errors.Errorf("query failed with status: %d - %s", proposalResponse.Response.Status, proposalResponse.Response.Message)
}
if strings.ToLower(i.Input.OutputFormat) == "json" {
return printResponseAsJSON(proposalResponse, &lb.QueryInstalledChaincodesResult{}, i.Writer)
}
return i.printResponse(proposalResponse)
}
// printResponse prints the information included in the response
// from the server.
func (i *InstalledQuerier) printResponse(proposalResponse *pb.ProposalResponse) error {
qicr := &lb.QueryInstalledChaincodesResult{}
err := proto.Unmarshal(proposalResponse.Response.Payload, qicr)
if err != nil {
return errors.Wrap(err, "failed to unmarshal proposal response's response payload")
}
fmt.Fprintln(i.Writer, "Installed chaincodes on peer:")
for _, chaincode := range qicr.InstalledChaincodes {View on GitHub (pinned to 2736b63f8f)
Solutions
- Read the status code/message in the error for the specific cause
- Check peer logs for the endorser error
- Verify the caller's identity satisfies lifecycle ACLs (e.g. _lifecycle/QueryInstalledChaincodes policy)
- Retry after the peer finishes startup if it was mid-boot
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-checks: peer joined to channel, caller MSP satisfies lifecycle ACLs // peer channel list && peer lifecycle chaincode installed --peerAddress ...
Try / catch
if err := q.Query(); err != nil {
if m := regexp.MustCompile(`status: (\d+) - (.*)`).FindStringSubmatch(err.Error()); m != nil {
code, _ := strconv.Atoi(m[1])
if code == 500 { return fmt.Errorf("peer internal error: %s", m[2]) }
if code == 403 { return fmt.Errorf("access denied by ACL: %s", m[2]) }
}
return err
} Prevention
- Review the _lifecycle/QueryInstalledChaincodes ACL policy
- Ensure the client identity/ MSP is correctly configured (TLS + membership)
- Wait for peer startup to complete before querying
- Check peer logs when a non-200 status appears
When it happens
Trigger: Peer-side failure of queryinstalled: caller lacks permission, peer internal error, or _lifecycle invocation rejected — Response.Status != 200 in the endorsement.
Common situations: ACLs denying the caller's role; peer still initializing/starting; TLS identity issues so the peer rejects the request; querying before any chaincode is installed (depending on peer version this can yield an error status).
Related errors
- query failed with status: %d - %s
- query iterator not found
- application config does not exist for channel '%s'
- unknown chaincode '%s' for channel '%s'
- could not find chaincode with package id '%s'
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/cb40caf23edc416b.
Report an issue: GitHub.