hyperledger/fabric · error
could not retrieve config block from index %d
Error message
could not retrieve config block from index %d
What it means
After finding the last config index encoded in the latest block, loadLastConfig tries to fetch that config block from the ledger and gets nil. The latest block claims a last-config index that the ledger cannot serve, so the stored last configuration cannot be loaded.
Source
Thrown at orderer/common/follower/follower_chain.go:591
}
}
c.logger.Debugf("Pulled blocks from %d to %d", firstBlockToPull, targetHeight)
return targetHeight - firstBlockToPull, nil
}
func (c *Chain) loadLastConfig() error {
height := c.ledgerResources.Height()
if height == 0 {
return errors.New("ledger is empty")
}
lastBlock := c.ledgerResources.Block(height - 1)
index, err := protoutil.GetLastConfigIndexFromBlock(lastBlock)
if err != nil {
return errors.WithMessage(err, "chain does have appropriately encoded last config in its latest block")
}
lastConfig := c.ledgerResources.Block(index)
if lastConfig == nil {
return errors.Errorf("could not retrieve config block from index %d", index)
}
c.lastConfig = lastConfig
return nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Reset/rollback the ledger to a consistent point (orderer rollback to a height where the config block exists) and re-sync from the ordering service.
- Restore the ledger from a snapshot or backup that includes the referenced config block.
- Check the block index storage (leveldb) for corruption; rebuild by re-pulling blocks via pullAfterJoin from a clean state.
- Re-join the channel entirely if the local ledger is unrecoverable, using a fresh join block.
Defensive patterns
Strategy: validation
Validate before calling
if idx, err := protoutil.GetLastConfigIndexFromBlock(lastBlock); err == nil { if idx >= ledgerResources.Height() { return errors.Errorf("last-config index %d out of range", idx) } } Try / catch
if err != nil && strings.Contains(err.Error(), "could not retrieve config block from index") { rollback ledger / restore snapshot, then re-sync } Prevention
- Avoid truncating the ledger past its last config block
- Perform clean shutdowns to protect block index DB integrity
- Keep recent ledger snapshots containing config blocks
- After unclean crashes, verify index consistency before restarting
When it happens
Trigger: loadLastConfig: protoutil.GetLastConfigIndexFromBlock(lastBlock) succeeds returning `index`, but c.ledgerResources.Block(index) returns nil — the referenced config block is missing from the ledger (truncation/pruning past the config block, or corrupted block index).
Common situations: Ledger files partially deleted or rolled back so the referenced config block no longer exists; corrupted index DB after unclean shutdown; a manually copied/mixed ledger directory where the newest block references config from a different ledger generation.
Related errors
- failed obtaining MSPs from MSPManager
- cannot retrieve previous block %d
- cannot enable channel capabilities without orderer support f
- Must set some OrdererAddresses
- no orderer section in config block
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/fea400a9e43a4d06.
Report an issue: GitHub.