<p>The error code that you posted tells you why it’s not working:</p>
<ol>
<li>the transaction you are looking for is not in the mempool</li>
<li>to query for a confirmed transaction, you need to either run a full node with transaction index or provide the block the transaction was in</li>
</ol>
<p>Since you do not seem to be running your node with transaction index, you should try to provide the blockhash.</p>
<p>Per the <a href="https://bitcoincore.org/en/doc/24.0.0/rpc/rawtransactions/getrawtransaction/" rel="nofollow noreferrer">RPC documentation</a> we learn that <code>getrawtransaction</code> takes up to three arguments with the latter two being optional:</p>
<p><code>bitcoin-cli getrawtransaction &quot;txid&quot; ( verbose &quot;blockhash&quot; )</code></p>
<ul>
<li>txid – the transaction you want to know about</li>
<li>verbose – false: return the hex-encoded full transaction, true: return a json object detailing the transaction</li>
<li>blockhash – the block the transaction was confirmed in</li>
</ul>
<p>So I suspect that your node should tell you what you want to know if you call</p>
<p><code>bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2 &lt;false/true&gt; 0000000000000001b6b9a13b095e96db41c4a928b97ef2d944a9b31b2cc7bdc4</code></p>
<p>in this specific case.</p>

CC BY-SA 4.0
2023-03-31T12:57:10.030Z
Thank you for the help!
Indul
CC BY-SA 4.0
2023-03-29T18:36:32.333Z
2023-03-29T20:57:07.497Z
2023-03-29T20:57:07.497Z
Murch
<pre><code>bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
error code: -5
error message:
No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries. Use gettransaction for wallet transactions.
[Rohan@fedora bitcoin]$ 
</code></pre>

CC BY-SA 4.0
2023-03-29T18:40:04.880Z
Hi Rohan, you had originally tagged this question as “Mastering Bitcoin”. It was not clear to me what the connection to the book was, so I removed the tag. If you think that this question is connected to the book, could you please clarify what the connection is in your question’s text and add the tag back?
Murch
<bitcoin-core><bitcoin-cli><getrawtransaction>
Why is `getrawtransaction` not working?
Indul
# Why is `getrawtransaction` not working?

(Asked by: username_0 on 2023-03-29)

```
bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
error code: -5
error message:
No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries. Use gettransaction for wallet transactions.
[Rohan@fedora bitcoin]$ 

```

**Tags:** bitcoin-core, bitcoin-cli, getrawtransaction

> **Comments:**
> **username_1**: Hi Rohan, you had originally tagged this question as “Mastering Bitcoin”. It was not clear to me what the connection to the book was, so I removed the tag. If you think that this question is connected to the book, could you please clarify what the connection is in your question’s text and add the tag back?  

---

## 1 answers

### Answer by username_1 on 2023-03-29. Score: 2

The error code that you posted tells you why it’s not working:

1. the transaction you are looking for is not in the mempool
2. to query for a confirmed transaction, you need to either run a full node with transaction index or provide the block the transaction was in

Since you do not seem to be running your node with transaction index, you should try to provide the blockhash.

Per the [RPC documentation](https://bitcoincore.org/en/doc/24.0.0/rpc/rawtransactions/getrawtransaction/) we learn that `getrawtransaction` takes up to three arguments with the latter two being optional:

`bitcoin-cli getrawtransaction "txid" ( verbose "blockhash" )`

* txid – the transaction you want to know about
* verbose – false: return the hex-encoded full transaction, true: return a json object detailing the transaction
* blockhash – the block the transaction was confirmed in

So I suspect that your node should tell you what you want to know if you call

`bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2 <false/true> 0000000000000001b6b9a13b095e96db41c4a928b97ef2d944a9b31b2cc7bdc4`

in this specific case.

> **Comments:**
> **username_0**: Thank you for the help!  

---

