<p>The &quot;accepted answer&quot; is technically correct but it's INCORRECT in its reasoning and doesn't explain that there are actually 2 RPC auth methods for bitcoind (which bitcoin-cli communicates with).</p>
<p>The commandline -rpcuser and -rpcpassword are NOT FOR rpcauth accounts.  That's the first problem that was never mentioned in the accepted answer.</p>
<p>It also failed to mention that you cannot use rpcauth creds from the bitcoin-cli command line app.  Bitcoind has 2 RPC auth methods,  only 1 of them is available via command line and that's the old one that's going to be removed.  After that, you're screwed.  No more command line access to bitcoind via bitcoin-cli (like that makes any sense ...).  You'll have to create your own script and connect to it over the RPC port without the use of bitcoin-cli from what I can tell.</p>
<p>For now you have to use rpcuser and rpcpass either on the command line or in bitcoin.conf file.  Perhaps rpcauth support will be added to the command line in the future for but at the moment, it doesn't appear like that's going to happen.</p>
<p>Anyway if anyone can actually show a real answer to this (that uses rpcauth from the bitcoin-cli command line app), feel free.  I see no way to use rpcauth from command line bitcoin-cli at the moment.  It looks like <a href="https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py</a> is going to replace it but currently all it does is generate passwords.  That's pretty useless as far as actually using any pre-built command line apps for communicating with bitcoind is concerned.</p>

CC BY-SA 4.0
2024-06-08T21:56:02.760Z
This is not correct. There are two mechanisms for configuring RPC authentication (rpcuser/rpcpassword, or rpcauth), but the -rpcuser/-rpcpassword arguments to `bitcoin-cli` is compatible with both. rpcauth is just a means of avoiding the cleartext password in the config file.
Pieter Wuille
CC BY-SA 4.0
2021-11-30T04:17:24.863Z
2021-12-07T14:51:54.680Z
2021-12-07T14:51:54.680Z
btc_to_da_moon
<p>Per <a href="https://bitcoin.stackexchange.com/a/112165/34190">this answer</a>, itself after <a href="https://howchoo.com/bitcoin/run-bitcoin-full-node-raspberry-pi/" rel="nofollow noreferrer">this guide</a>, you may get the <code>Could not locate RPC credentials</code> message if <code>bitcoin-cli</code> is not looking in the right place for the datadir. You can explicitly tell it where to look:</p>
<pre><code>bitcoin-cli -datadir=/path/to/your/datadir YOUR_COMMMAND
</code></pre>

CC BY-SA 4.0
2024-06-08T17:15:34.337Z
2024-06-08T17:15:34.337Z
Lee
<p>Try to use the old authentication way which i always been using and has no issue</p>

<pre><code>#rpcuser=USER
#rpcpassword=PASS
</code></pre>

CC BY-SA 3.0
2018-04-18T21:17:00.977Z
2018-04-18T21:17:00.977Z
zhiyan114
<p>You are using <code>bitcoin-cli</code> incorrectly.</p>

<p>The command line arguments come before the RPC command. Anything that comes after the RPC command will be interpreted as arguments for the RPC, not arguments to <code>bitcoin-cli</code></p>

<p>So what you should actually be doing is </p>

<pre><code>src/bitcoin-cli -rpcuser={...} -rpcpassword={...} getblockchaininfo
</code></pre>

CC BY-SA 4.0
2018-04-18T15:34:30.250Z
2019-05-11T16:29:29.550Z
2019-05-11T16:29:29.550Z
Ava Chow
<p>I'm running a bitcoind 0.16 and it seem working, blockchain in sync etc..
I've used the "new" rpcauth, which is non deprecated so kind of referennce as explained here: <a href="https://github.com/bitcoin/bitcoin/blob/v0.16.0/contrib/debian/examples/bitcoin.conf" rel="noreferrer">https://github.com/bitcoin/bitcoin/blob/v0.16.0/contrib/debian/examples/bitcoin.conf</a>. I've generated the rpcauth line and the password with
<code>./share/rpcauth/rpcauth.py bob</code></p>

<p>Copied the rpc line in the ~/.bitcoin/bitcoin.conf file and stored the password elsewhere. The conf file have this [rpc] section:</p>

<pre><code>server=1
rest=1
rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99
</code></pre>

<p>I run</p>

<pre><code>./src/bitcoin-cli get blockchaininfo -rpcuser={...} -rpcpassword={...}
</code></pre>

<p>The answer is:</p>

<pre><code>error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/bitcoin/.bitcoin/bitcoin.conf)
</code></pre>

<p>It's like the cli can't read the rpc credentials from the command line. It's not saying "credentials are wrong". Also the conf file is the correct one so...</p>

<p>Any clue? </p>

<json-rpc><bitcoin-cli><rpc-error-25>
bitcoin-cli could not locate RPC credentials
Daniele Dellafiore
# bitcoin-cli could not locate RPC credentials

(Asked by: username_0 on 2018-04-18)

I'm running a bitcoind 0.16 and it seem working, blockchain in sync etc..
I've used the "new" rpcauth, which is non deprecated so kind of referennce as explained here: <https://github.com/bitcoin/bitcoin/blob/v0.16.0/contrib/debian/examples/bitcoin.conf>. I've generated the rpcauth line and the password with
`./share/rpcauth/rpcauth.py bob`

Copied the rpc line in the ~/.bitcoin/bitcoin.conf file and stored the password elsewhere. The conf file have this [rpc] section:

```
server=1
rest=1
rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99

```

I run

```
./src/bitcoin-cli get blockchaininfo -rpcuser={...} -rpcpassword={...}

```

The answer is:

```
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/bitcoin/.bitcoin/bitcoin.conf)

```

It's like the cli can't read the rpc credentials from the command line. It's not saying "credentials are wrong". Also the conf file is the correct one so...

Any clue?

**Tags:** json-rpc, bitcoin-cli, rpc-error-25


---

## 4 answers

### Answer by username_5 on 2018-04-18. Score: 9 | Accepted answer

You are using `bitcoin-cli` incorrectly.

The command line arguments come before the RPC command. Anything that comes after the RPC command will be interpreted as arguments for the RPC, not arguments to `bitcoin-cli`

So what you should actually be doing is

```
src/bitcoin-cli -rpcuser={...} -rpcpassword={...} getblockchaininfo

```


---

### Answer by username_1 on 2021-11-30. Score: 1

The "accepted answer" is technically correct but it's INCORRECT in its reasoning and doesn't explain that there are actually 2 RPC auth methods for bitcoind (which bitcoin-cli communicates with).

The commandline -rpcuser and -rpcpassword are NOT FOR rpcauth accounts. That's the first problem that was never mentioned in the accepted answer.

It also failed to mention that you cannot use rpcauth creds from the bitcoin-cli command line app. Bitcoind has 2 RPC auth methods, only 1 of them is available via command line and that's the old one that's going to be removed. After that, you're screwed. No more command line access to bitcoind via bitcoin-cli (like that makes any sense ...). You'll have to create your own script and connect to it over the RPC port without the use of bitcoin-cli from what I can tell.

For now you have to use rpcuser and rpcpass either on the command line or in bitcoin.conf file. Perhaps rpcauth support will be added to the command line in the future for but at the moment, it doesn't appear like that's going to happen.

Anyway if anyone can actually show a real answer to this (that uses rpcauth from the bitcoin-cli command line app), feel free. I see no way to use rpcauth from command line bitcoin-cli at the moment. It looks like <https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py> is going to replace it but currently all it does is generate passwords. That's pretty useless as far as actually using any pre-built command line apps for communicating with bitcoind is concerned.

> **Comments:**
> **username_2**: This is not correct. There are two mechanisms for configuring RPC authentication (rpcuser/rpcpassword, or rpcauth), but the -rpcuser/-rpcpassword arguments to `bitcoin-cli` is compatible with both. rpcauth is just a means of avoiding the cleartext password in the config file.  

---

### Answer by username_3 on 2024-06-08. Score: 0

Per [this answer](https://bitcoin.stackexchange.com/a/112165/34190), itself after [this guide](https://howchoo.com/bitcoin/run-bitcoin-full-node-raspberry-pi/), you may get the `Could not locate RPC credentials` message if `bitcoin-cli` is not looking in the right place for the datadir. You can explicitly tell it where to look:

```
bitcoin-cli -datadir=/path/to/your/datadir YOUR_COMMMAND

```


---

### Answer by username_4 on 2018-04-18. Score: 0

Try to use the old authentication way which i always been using and has no issue

```
#rpcuser=USER
#rpcpassword=PASS

```


---

