<p>The RPC interface is an authenticated interface. You need to provide a username and password in order to send RPC commands. These are usually specified in the bitcoin.conf file with the <code>rpcuser</code> and <code>rpcpassword</code> options or the <code>rpcauth</code> option. There are also temporary RPC credentials stored in the <code>.cookie</code> file that can be found in the datadir.</p>

<p>The reason that you have no problems with <code>bitcoin-cli</code> is because it looks up the RPC credentials from the bitcoin.conf file or the <code>.cookie</code> file..</p>

CC BY-SA 4.0
2022-02-02T21:24:41.483Z
should bitcoin core accept authentication if I manually set `bitcoind.rpcuser="__cookie__"` and `bitcoind.rpcpass=<value from .cookie file>` ?
pseudozach
CC BY-SA 4.0
2018-07-15T08:36:12.377Z
2018-07-15T08:36:12.377Z
Ava Chow
<p>I was struggling a lot as well till recognise the right configuration naming</p>

<p>bitcoin.conf</p>

<pre><code>rpcuser=
rpcpassword=
</code></pre>

<p>lnd.conf</p>

<pre><code>bitcoind.rpcuser=
bitcoind.rpcpass=
</code></pre>

CC BY-SA 4.0
2020-02-17T09:06:40.013Z
2020-02-17T09:06:40.013Z
Allan Clempe
<p>I am using <code>node-bitcoin-rpc</code> to do some api calls to bitcoind, but I am getting 401 error. I know this simply means unauthorized, but I have no authorization enable in my config file.</p>

<p>Howerver I can query bitcoin client using <code>vitcoin-cli --regtest listaccounts</code>, I get the results.</p>

<p>My bitcoin.conf file is pretty simple</p>

<pre><code>rpcport=8332
rpcconnect=127.0.0.1
regtest=1
debug=rpc
</code></pre>

<p>PS: I didn't have any bitcoin.conf initially, so I create above one inside .bitcoin folder in home directory.</p>

<bitcoind><json-rpc>
Bitcoin RPC returning 401
Prashant Prabhakar Singh
# Bitcoin RPC returning 401

(Asked by: username_0 on 2018-07-15)

I am using node-bitcoin-rpc to do some api calls to bitcoind, but I am getting 401 error. I know this simply means unauthorized, but I have no authorization enable in my config file.
Howerver I can query bitcoin client using vitcoin-cli --regtest listaccounts, I get the results.
My bitcoin.conf file is pretty simple
rpcport=8332
rpcconnect=127.0.0.1
regtest=1
debug=rpc

PS: I didn't have any bitcoin.conf initially, so I create above one inside .bitcoin folder in home directory.

**Tags:** bitcoind, json-rpc


---

## 2 answers

### Answer by username_1 on 2018-07-15. Score: 1

The RPC interface is an authenticated interface. You need to provide a username and password in order to send RPC commands. These are usually specified in the bitcoin.conf file with the `rpcuser` and `rpcpassword` options or the `rpcauth` option. There are also temporary RPC credentials stored in the `.cookie` file that can be found in the datadir.

The reason that you have no problems with `bitcoin-cli` is because it looks up the RPC credentials from the bitcoin.conf file or the `.cookie` file..

> **Comments:**
> **username_2**: should bitcoin core accept authentication if I manually set `bitcoind.rpcuser="__cookie__"` and `bitcoind.rpcpass=<value from .cookie file>` ?  

---

### Answer by username_3 on 2020-02-17. Score: 1

I was struggling a lot as well till recognise the right configuration naming
bitcoin.conf
rpcuser=
rpcpassword=

lnd.conf
bitcoind.rpcuser=
bitcoind.rpcpass=


---

