Skip to content
BTC— ETH— SOL— ETH gas— Hashrate— Block— mempool.space · CoinGecko

Bitcoin Core reindex: choose the right database rebuild

Match the failing database to the rebuild, check pruning before starting, and separate index completion from chainstate catch-up and wallet scans.

An engraved archive of chained Bitcoin blocks connected by blue routes to a separate indexing mechanism being reassembled
Contents

    Use -reindex-chainstate when Bitcoin Core needs to rebuild its UTXO database and the block index and required block history are intact. Use -reindex when the block index also needs rebuilding, or a pruned node requires a rebuild. Both are startup options that discard derived databases; protect your wallets and establish the failing layer before launching either one. A wallet rescan solves a different problem.

    I'd start with the exact error and the storage configuration. Choosing the smaller rebuild can save work, but only if it retains a usable block index and enough history. Repeating a rebuild against a failing drive can leave you with the same error and fewer useful clues.

    Preserve wallets and check the failure first

    Save the startup error and the surrounding debug.log entries before changing anything. Record the Core version and network, then identify the data directory and any separate block-storage directory. Check that the intended drive is mounted, writable and has free space. An absent external drive or a different network directory needs a configuration correction before a database rebuild.

    Core's file-layout reference separates wallet data from blockchain data. For a loaded, functioning wallet, it recommends backupwallet for a consistent backup. If Core can't open, shut it down completely before preserving the wallet directory, including associated journal files. Keep the original copy safe. Rebuilt blocks and chainstate cannot replace missing private keys.

    For repeated I/O or filesystem errors, pause recovery writes and preserve the affected storage before attempting another rebuild. Don't start by deleting individual LevelDB files. Core's startup checks also distinguish a wrong network directory from corruption, and tell you to check the computer's clock before rebuilding a database containing an apparently future-dated block.

    If this is a new installation with uncertain paths or service settings, settle the node setup and storage configuration first. Appliance and container installations need their own service controls; a command copied from an old support thread may address a different instance.

    Separate block data, indexes and the wallet

    The blk*.dat files contain the blocks themselves. The LevelDB database in blocks/index/ records the block index. The chainstate/ database holds the current unspent transaction outputs, or UTXOs, with associated metadata. The wallet tracks its own keys and transactions separately. These are different stores even when they sit under one data directory.

    A separate -blocksdir moves the block-data location, but it doesn't move blocks/index/. When preserving modern block files, retain their xor.dat file too: the block-storage implementation uses the stored XOR key to read the corresponding data. A folder of block files is therefore not interchangeable with a wallet backup or a complete node backup.

    OperationData rebuiltSuitable branch
    -reindex-chainstateDiscards and rebuilds chainstate using the existing block index and block files.Chainstate-specific failure on an unpruned node with the necessary intact history. Doesn't repair a broken block index.
    -reindexDiscards and rebuilds the block index and chainstate. Also rebuilds active optional indexes.Block-index rebuild, or a rebuild required with pruning. Missing or damaged history can require downloads; this doesn't repair a faulty drive.
    Wallet rescanSearches available block history for transactions relevant to the selected wallet.The node works, but a restored or newly imported wallet needs transaction history. Doesn't rebuild the node databases or restore missing keys.

    The Core 32.1 startup-option definitions specify the rebuild scope. A loaded AssumeUTXO snapshot's chainstate is wiped by either rebuild option too; it isn't preserved as a shortcut through the operation. Plan for that consequence before changing a snapshot-based node.

    Match the error and pruning state to the operation

    An explicit Unsupported chainstate database format found or Unable to replay blocks message identifies a chainstate-rebuild branch in Core's startup code. With an intact block index and required block files on an unpruned node, the narrower option avoids rebuilding the block index. A generic database-open failure needs the surrounding log and storage checks; its wording alone doesn't prove which file is damaged.

    With pruning enabled, Core rejects -reindex-chainstate with Prune mode is incompatible with -reindex-chainstate. Use full -reindex instead. Turning pruning off doesn't recreate deleted history. Core explicitly requires a full rebuild and blockchain redownload when returning a previously pruned data directory to unpruned operation.

    Budget bandwidth as well as processing time for a pruned rebuild. In pruning mode, full reindex cleanup removes unusable later block files after a gap and rewrites undo data. A small retained set of recent blocks cannot rebuild the entire history locally. Don't assume the disk space currently used by a pruned node represents the download work ahead.

    An error naming txindex points to an optional index, which is distinct from the block index. I'd keep that distinction in the support report rather than starting a wallet rescan. A full -reindex also rebuilds optional indexes that are active, so account for their extra work and for applications that depend on them.

    Pass the chosen flag at startup

    These flags belong to the node executable's startup arguments. They aren't RPC commands for the Console or bitcoin-cli. First stop the existing node cleanly and wait for it to exit. For a service or appliance, use its supported stop and recovery controls so it doesn't restart another process against the same directory.

    The following are documented command forms for a standalone daemon, not a diagnosis or a script to run unchanged. Replace the quoted path with the confirmed absolute data-directory path. Preserve the installation's network, configuration and separate block-directory options. Choose only the line justified by the checks above.

    bitcoind -datadir="/absolute/path/to/bitcoin-data" -reindex-chainstate
    bitcoind -datadir="/absolute/path/to/bitcoin-data" -reindex

    The first line requires pruning to be disabled and the necessary block history to be present. The second has the broader wipe-and-rebuild scope described above. Use the executable and account belonging to your installation; don't launch an unrelated host daemon to repair a container's node. The RaspiBlitz recovery discussion shows why the correct service account and stopping the existing service matter, while its old commands aren't a universal appliance procedure.

    If a recovery setting was added permanently to a configuration file, remove that temporary setting after recovery. Leaving it enabled requests another wipe at startup. Likewise, a restart intended to continue interrupted work should use the normal startup configuration, without requesting a fresh rebuild again.

    Use Core's published checks to assess the expected behavior

    Core's reindex functional test alternates the two startup modes and checks that the node returns to the preceding block count. It also tests out-of-order block data and an orderly shutdown during reindexing. These assertions show the behavior recovery should preserve; they don't provide a completion-time estimate for your hardware.

    Published scenarioAssertionPractical implication
    Restart with either rebuild flag after generating more blocksThe block count after startup equals the block count before shutdown.Expect the reconstructed node to recover the available validated chain, not merely open a blank database.
    Swap block order within a test block file, then full reindexThe node processes out-of-order children and returns to height 12.Physical block order needn't match chain order. Don't manually rearrange production block files.
    Orderly stop during full reindex, then normal restartThe active block-filter index database is opened without being wiped again.Distinguish resuming work from explicitly requesting a new rebuild.
    Start with pruning and chainstate-only reindexThe pruning functional test expects startup to reject that combination.Use the pruning branch before selecting a flag.

    The narrower operation skips block-index reconstruction, but substantial block processing remains. Storage performance and memory pressure still matter. Core's memory guidance identifies sustained swapping as a cause of severe slowdown during sync or reindex, and recommends reducing -dbcache when that occurs. Increasing the cache without checking available memory can make that situation worse.

    Check chain progress after index reconstruction

    A Reindexing finished log line marks the end of block-file indexing in the import code. Chainstate processing and catch-up can still remain. Don't use that single message, or an appliance's unchanged “Starting” label, as the completion test. While RPC is unavailable during startup, follow the existing process's log; don't start another node just to obtain a status response.

    Once RPC is available, getblockchaininfo reports the node's chain-processing state. In the Qt Console, help getblockchaininfo displays the installed version's field definitions; the unsubmitted input below shows that help request. The node-state query itself is getblockchaininfo.

    Bitcoin Core Console with help getblockchaininfo entered in the bottom input and no command output
    Read the field definitions with help getblockchaininfo before interpreting the node-state response. Select Enlarge image to read the details.

    The RPC field reference distinguishes blocks, the validated chain height, from headers, the validated header count. Watch chain progress over time, inspect the best-block hash and warnings, and check that the expected network is selected. verificationprogress and initialblockdownload are estimates, so one favorable value doesn't establish that every dependent application has caught up.

    The pruned field identifies pruning mode; pruneheight, when present, identifies the first unpruned block. Optional backgroundvalidation reports snapshot-related historical validation separately. An up-to-date active chain doesn't by itself establish that a wallet scan or another application's index is complete.

    Stop repeating the rebuild when the same fault returns

    Save the new exact error and its point of failure. Repeated corruption after rebuilding calls for investigation of storage integrity, connections, power and the applicable software version. It doesn't justify deleting more directories or changing firmware on speculation. An inability to read drive-health data also isn't proof that the drive is healthy or faulty.

    If the node's chain is healthy but a restored wallet still lacks transactions, investigate the wallet's scan range and available history next. Keep that separate from node-database repair. For a database support request, provide the Core version, network and pruning state, the operation attempted, and redacted log excerpts. Remove RPC credentials and private wallet information. The node library keeps setup and related Core tasks together.

    All about Bitcoin nodes