<p>Keep in mind that the configuration file <strong>is not automatically</strong> created; you can create it using your favorite text editor. By default, the configuration file name is <code>bitcoin.conf</code> and it is located in the Bitcoin data directory, but both the Bitcoin data directory and the configuration file path may be changed using the <code>-datadir</code> and <code>-conf</code> command-line options. Also, do not forget to set the appropriate file permissions and restart the <code>bitcoind</code>.</p>

CC BY-SA 4.0
2021-10-27T13:56:11.137Z
2021-10-27T13:56:11.137Z
bodi0
<p>Found it out, you just need to give it a username and password. You can add them to a <code>bitcoin.conf</code> file in your datadir. This file isn't automatically created. The default datadir is at <code>~/.bitcoin</code>, so you can make a <code>~/.bitcoin/bitcoin.conf</code></p>
<pre><code>rpcuser=user
rpcpassword=pass
</code></pre>
<hr />
<p>Additionally, if you'd like, you can later pass your username and passwords as URL parameters, like so:</p>
<pre><code>http://user:password@IP_ADDRESS:PORT
</code></pre>

CC BY-SA 4.0
2021-10-27T03:40:49.430Z
2021-10-27T19:15:31.047Z
2021-10-27T19:15:31.047Z
Patrick Collins
<p>According to the <a href="https://developer.bitcoin.org/reference/rpc/getbestblockhash.html" rel="nofollow noreferrer">bitcoin documentation</a> I can make <code>curl</code> calls to my bitcoin node. However, whenever I run a curl command like the following (as per the docs):</p>
<pre><code>curl --data-binary '{&quot;jsonrpc&quot;: &quot;1.0&quot;, &quot;id&quot;: &quot;curltest&quot;, &quot;method&quot;: &quot;getbestblockhash&quot;, &quot;params&quot;: []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
</code></pre>
<p>I get no response. But when I run the <code>bitcoin-cli</code> edition:</p>
<pre><code>bitcoin-cli getbestblockhash
</code></pre>
<p>I get a response.</p>
<p>So what is the difference? What am I missing?</p>
<p>I've seen <a href="https://bitcoin.stackexchange.com/questions/84464/bitcoin-curl-no-reply">this</a> and <a href="https://bitcoin.stackexchange.com/questions/83165/json-rpc-of-bitcoin-not-working-for-testnetcurl-command">this</a> but they were never resolved.</p>

<bitcoind><json-rpc><api><bitcoin-cli>
Bitcoin-cli responding but not curl
Patrick Collins
# Bitcoin-cli responding but not curl

(Asked by: username_0 on 2021-10-27)

According to the bitcoin documentation I can make curl calls to my bitcoin node. However, whenever I run a curl command like the following (as per the docs):
curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getbestblockhash", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

I get no response. But when I run the bitcoin-cli edition:
bitcoin-cli getbestblockhash

I get a response.
So what is the difference? What am I missing?
I've seen this and this but they were never resolved.

**Tags:** bitcoind, json-rpc, api, bitcoin-cli


---

## 2 answers

### Answer by username_0 on 2021-10-27. Score: 5 | Accepted answer

Found it out, you just need to give it a username and password. You can add them to a bitcoin.conf file in your datadir. This file isn't automatically created. The default datadir is at ~/.bitcoin, so you can make a ~/.bitcoin/bitcoin.conf
rpcuser=user
rpcpassword=pass


Additionally, if you'd like, you can later pass your username and passwords as URL parameters, like so:
http://user:password@IP_ADDRESS:PORT


---

### Answer by username_1 on 2021-10-27. Score: 2

Keep in mind that the configuration file **is not automatically** created; you can create it using your favorite text editor. By default, the configuration file name is `bitcoin.conf` and it is located in the Bitcoin data directory, but both the Bitcoin data directory and the configuration file path may be changed using the `-datadir` and `-conf` command-line options. Also, do not forget to set the appropriate file permissions and restart the `bitcoind`.


---

