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

  1. Read the status code/message in the error for the specific cause
  2. Check peer logs for the endorser error
  3. Verify the caller's identity satisfies lifecycle ACLs (e.g. _lifecycle/QueryInstalledChaincodes policy)
  4. 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

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


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/cb40caf23edc416b. Report an issue: GitHub.