Run bitcoin-cli from a different user on the same machine

Salvador Guerrero
1 min readSep 5, 2023

If you run bitcoin-cli from a different user that the one running bitcoind you will encounter the following error:

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/satoshi/.bitcoin/bitcoin.conf)

To fi this, you just need to create a new bitcoin.conf file on your home directory, and point to the cookie file

# Create the .bitcoin directory if it doesn't exist
mkdir ~/.bitcoin

# create the bitcoin.conf
vi ~/.bitcoin/bitcoin.conf

Once Vim opens, paste the following; replacing my path to your Bitcoin data directory

rpccookiefile=/mnt/sda/bitcoin/.cookie

Save and re-run the bitcoin-cli command, if it still doesn’t work fix the permissions as follows:

sudo chmod o+rx /mnt/sda/bitcoin/.cookie 

The permissions will get reverted every time bitcoind restarts, to permanently fix this add the following to your bitcoin.conf so it adds read and execute permissions for other users to the .cookie file on startup

startupnotify=chmod o+rx /mnt/sda/bitcoin/.cookie

And that’s it, I hope it helps!

--

--

Salvador Guerrero

Computer Science Engineer, Cross-Platform App Developer, Open Source contributor. 🇲🇽🇺🇸