<p>Just run <code>./bitcoind -reindex</code> and this will fix your problem.</p>

<p><code>-rescan</code> is for missing wallet transactions</p>

CC BY-SA 3.0
2013-10-09T16:35:13.910Z
2013-10-09T16:35:13.910Z
ManreeRist
<p>Try to look in the <code>~/.bitcoin/db.log</code> file for more information. It is likely that your only solution is to remove the block database (either <code>blk0001.dat</code>,  <code>blk0002.dat</code> or <code>blkindex.dat</code>). <strong>DO NOT REMOVE YOUR</strong> <code>wallet.dat</code> file!!!</p>

<p>This means you will have to download the whole block chain again. <a href="https://bitcoin.stackexchange.com/questions/5876/how-can-i-recover-from-a-corrupted-blkindex-dat-on-ubuntu-12-10">This other question</a> has tips on how to speed up that download.</p>

<p>Note that this may just be another case of the question asked <a href="https://bitcoin.stackexchange.com/questions/5876/how-can-i-recover-from-a-corrupted-blkindex-dat-on-ubuntu-12-10">here</a>.</p>

CC BY-SA 3.0
2013-10-09T17:51:55.917Z
Don't advise people to wipe their data directories. Since 0.8, we have -reindex which rebuilds them without redownloading.
Pieter Wuille
CC BY-SA 3.0
2013-02-18T20:34:53.747Z
2013-02-18T20:34:53.747Z
2017-04-13T12:47:32.940Z
anarcat
<pre><code>looris@Palace-of-the-Nine-Moons:/tmp $ bitcoind 
looris@Palace-of-the-Nine-Moons:/tmp $ Bitcoin server starting


************************
EXCEPTION: St13runtime_error       
CLevelDB(): error opening database environment Corruption: missing start of fragmented record(2)       
bitcoin in AppInit()       
</code></pre>

<p>This happens when I start <code>bitcoind</code>, any clue on what could I do to fix it?</p>

<p>I tried to run it with <code>-rescan</code> but the result was the same.</p>

CC BY-SA 3.0
2013-02-13T23:25:40.240Z
I suspect it would be faster to redownload the blockchain than fix this, but [here's where your error is being thrown from](https://github.com/bitcoin/bitcoin/blob/master/src/leveldb.cpp#L57)
Nick ODell
CC BY-SA 3.0
2013-02-13T23:42:53.523Z
@NickODell doing it, but it takes me more than 24h to download it all, if this bug happens again I'd really need a quicker way to fix it...
o0'.
CC BY-SA 3.0
2013-02-14T00:04:17.757Z
Agreed. Actually, [this](https://github.com/bitcoin/bitcoin/blob/master/src/leveldb/db/log_reader.cc#L124) seems more relevant to your problem. It would appear that if it loads a record of type kLastType which isn't preceeded by kFirstType, then it will put out that error message.
Nick ODell
CC BY-SA 3.0
2013-02-14T09:50:59.717Z
@NickODell oh thank you, that would be useful. Now I'm re-downloading anyway, but I've not deleted the corrupted db yet...
o0'.
CC BY-SA 3.0
2013-02-18T22:28:00.393Z
You need -reindex, not -rescan (which is for finding missing wallet transactions).
Pieter Wuille
<bitcoind>
bitcoind: corrupted database?
o0'.
# bitcoind: corrupted database?

(Asked by: username_0 on 2013-02-13)

```
looris@Palace-of-the-Nine-Moons:/tmp $ bitcoind 
looris@Palace-of-the-Nine-Moons:/tmp $ Bitcoin server starting

************************
EXCEPTION: St13runtime_error       
CLevelDB(): error opening database environment Corruption: missing start of fragmented record(2)       
bitcoin in AppInit()       

```

This happens when I start `bitcoind`, any clue on what could I do to fix it?

I tried to run it with `-rescan` but the result was the same.

**Tags:** bitcoind

> **Comments:**
> **username_1**: I suspect it would be faster to redownload the blockchain than fix this, but [here's where your error is being thrown from](https://github.com/bitcoin/bitcoin/blob/master/src/leveldb.cpp#L57)  
> **username_0**: @username_1 doing it, but it takes me more than 24h to download it all, if this bug happens again I'd really need a quicker way to fix it...  
> **username_1**: Agreed. Actually, [this](https://github.com/bitcoin/bitcoin/blob/master/src/leveldb/db/log_reader.cc#L124) seems more relevant to your problem. It would appear that if it loads a record of type kLastType which isn't preceeded by kFirstType, then it will put out that error message.  
> **username_0**: @username_1 oh thank you, that would be useful. Now I'm re-downloading anyway, but I've not deleted the corrupted db yet...  
> **username_2**: You need -reindex, not -rescan (which is for finding missing wallet transactions).  

---

## 2 answers

### Answer by username_3 on 2013-10-09. Score: 4

Just run `./bitcoind -reindex` and this will fix your problem.

`-rescan` is for missing wallet transactions


---

### Answer by username_4 on 2013-02-18. Score: 0

Try to look in the `~/.bitcoin/db.log` file for more information. It is likely that your only solution is to remove the block database (either `blk0001.dat`, `blk0002.dat` or `blkindex.dat`). **DO NOT REMOVE YOUR** `wallet.dat` file!!!

This means you will have to download the whole block chain again. [This other question](https://bitcoin.stackexchange.com/questions/5876/how-can-i-recover-from-a-corrupted-blkindex-dat-on-ubuntu-12-10) has tips on how to speed up that download.

Note that this may just be another case of the question asked [here](https://bitcoin.stackexchange.com/questions/5876/how-can-i-recover-from-a-corrupted-blkindex-dat-on-ubuntu-12-10).

> **Comments:**
> **username_2**: Don't advise people to wipe their data directories. Since 0.8, we have -reindex which rebuilds them without redownloading.  

---

