Bitcoin restart loop with "Error: txindex: best block of the index not found. Please rebuild the index."

How can I rebuild the index per the message in the log?

Server Pure has been installed/running fine for a month or two.
Bitcoin service and Electrs have been working fine.
I opened a few Electrum wallets around the same time (pointed at this Electrs instance). One connected and showed the history, the other two spun for a bit then went red (indicating no connection) at which point the connected one also went red.
I looked at the status of the services in StartOS web UI, and Bitcoin appeared to be restarting. Looking further, it was in a restart loop. This is a core part of the loop with the error near the end.

2024-06-18T09:12:09-05:00  2024-06-18T14:12:09Z Checking all blk files are present...
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Initializing chainstate Chainstate [ibd] @ height -1 (null)
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Opening LevelDB in /root/.bitcoin/chainstate
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Opened LevelDB successfully
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Using obfuscation key for /root/.bitcoin/chainstate: 7fc77f9aab1c636b
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Loaded best chain: hashBestChain=000000000000000000032c6c73aaf104a1c9c27949f39408096715a1cad58591 height=848195 date=2024-06-16T15:05:50Z progress=0.998914
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Opening LevelDB in /root/.bitcoin/chainstate
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Opened LevelDB successfully
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Using obfuscation key for /root/.bitcoin/chainstate: 7fc77f9aab1c636b
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z [Chainstate [ibd] @ height 848195 (000000000000000000032c6c73aaf104a1c9c27949f39408096715a1cad58591)] resized coinsdb cache to 8.0 MiB
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z [Chainstate [ibd] @ height 848195 (000000000000000000032c6c73aaf104a1c9c27949f39408096715a1cad58591)] resized coinstip cache to 335.0 MiB
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z init message: Verifying blocks…
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Verifying last 6 blocks at level 3
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Verification progress: 0%
2024-06-18T09:12:10-05:00  2024-06-18T14:12:10Z Verification progress: 16%
2024-06-18T09:12:11-05:00  2024-06-18T14:12:11Z Verification progress: 33%
2024-06-18T09:12:11-05:00  2024-06-18T14:12:11Z Verification progress: 50%
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Verification progress: 66%
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Verification progress: 83%
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Verification progress: 99%
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Verification: No coin database inconsistencies in last 6 blocks (24759 transactions)
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z  block index            8004ms
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Opening LevelDB in /root/.bitcoin/indexes/txindex
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Opened LevelDB successfully
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Using obfuscation key for /root/.bitcoin/indexes/txindex: 0000000000000000
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Opening LevelDB in /root/.bitcoin/indexes/blockfilter/basic/db
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Opened LevelDB successfully
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Using obfuscation key for /root/.bitcoin/indexes/blockfilter/basic/db: 0000000000000000
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Error: txindex: best block of the index not found. Please rebuild the index.
2024-06-18T09:12:12-05:00  Error: txindex: best block of the index not found. Please rebuild the index.
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Shutdown: In progress...
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z scheduler thread exit
2024-06-18T09:12:12-05:00  2024-06-18T14:12:12Z Flushed fee estimates to fee_estimates.dat.
2024-06-18T09:12:13-05:00  2024-06-18T14:12:13Z Shutdown: done

You can find Reindex Blockchain under the Actions menu for Bitcoin Core. Electrs will not function properly until the Bitcoin Core health checks are good. Let us know how it goes!

1 Like

Thanks. Very cool to have that as an action in the UI. It’s working on it now.

EDIT: It took over a day, but it worked. Thanks!

2 Likes