<p>You can enable the <code>txindex</code> by either adding it to your <code>bitcoin.conf</code> file:</p>

<pre><code>txindex=1
</code></pre>

<p>or</p>

<p>You can run <code>bitcoind</code> with the <code>-txindex</code> flag:</p>

<pre><code>$ bitcoind -txindex
</code></pre>

<p>See:</p>

<pre><code>$ bitcoind --help

    -txindex
       Maintain a full transaction index, used by the getrawtransaction rpc
       call (default: 0)
</code></pre>

CC BY-SA 4.0
2018-11-18T06:08:51.893Z
but reindexing is necessary correct?
SantiClaus
CC BY-SA 4.0
2018-11-18T16:19:51.853Z
Yes you might need to also use the `-reindex` flag. You might also want to set a higher `-dbcache` to speed it up.
JBaczuk
CC BY-SA 4.0
2018-11-18T17:36:04.423Z
One more question, and thanks again. If I do not shut out of the ubuntu command prompt correctly, for example if I have to restart it or if it shuts down unexpectedly, can it corrupt the data?
SantiClaus
CC BY-SA 4.0
2018-11-18T18:07:49.990Z
And will I know if the database is corrupted? For example, will the program notify me?
SantiClaus
CC BY-SA 4.0
2018-11-18T18:16:58.533Z
If you set the `-daemon` flag it will run in the background and you can close the terminal. If it shuts down, it may corrupt the data, but you should see errors in `~/.bitcoin/debug.log`
JBaczuk
CC BY-SA 4.0
2018-11-18T19:06:02.863Z
would I have to run the file `debug.log` or just click into it? Basically how would I tell?
SantiClaus
CC BY-SA 4.0
2018-11-19T02:15:04.280Z
it is a text file, but I think the application will crash if the data is corrupted. Either way, you can watch the log file with `$ tail -f ~/.bitcoin/debug.log`
JBaczuk
CC BY-SA 4.0
2018-11-17T01:38:21.623Z
2018-11-17T01:38:21.623Z
JBaczuk
<p>I am using bitcoin.rpc.RawProxy to connect to bitcoind and scrape the data. But I am getting an error when I <code>gettransaction</code> and I have to reindex the blockchain. Thus I am wondering how I set the txindex to 1 so I can reindex and continue.</p>

<bitcoin-core><bitcoind><txindex>
How do you set txindex to 1?
SantiClaus
# How do you set txindex to 1?

(Asked by: username_0 on 2018-11-16)

I am using bitcoin.rpc.RawProxy to connect to bitcoind and scrape the data. But I am getting an error when I `gettransaction` and I have to reindex the blockchain. Thus I am wondering how I set the txindex to 1 so I can reindex and continue.

**Tags:** bitcoin-core, bitcoind, txindex


---

## 1 answers

### Answer by username_1 on 2018-11-17. Score: 2 | Accepted answer

You can enable the `txindex` by either adding it to your `bitcoin.conf` file:

```
txindex=1

```

or

You can run `bitcoind` with the `-txindex` flag:

```
$ bitcoind -txindex

```

See:

```
$ bitcoind --help

    -txindex
       Maintain a full transaction index, used by the getrawtransaction rpc
       call (default: 0)

```

> **Comments:**
> **username_0**: but reindexing is necessary correct?  
> **username_1**: Yes you might need to also use the `-reindex` flag. You might also want to set a higher `-dbcache` to speed it up.  
> **username_0**: One more question, and thanks again. If I do not shut out of the ubuntu command prompt correctly, for example if I have to restart it or if it shuts down unexpectedly, can it corrupt the data?  
> **username_0**: And will I know if the database is corrupted? For example, will the program notify me?  
> **username_1**: If you set the `-daemon` flag it will run in the background and you can close the terminal. If it shuts down, it may corrupt the data, but you should see errors in `~/.bitcoin/debug.log`  
> **username_0**: would I have to run the file `debug.log` or just click into it? Basically how would I tell?  
> **username_1**: it is a text file, but I think the application will crash if the data is corrupted. Either way, you can watch the log file with `$ tail -f ~/.bitcoin/debug.log`  

---

