<p>You need to pass the same <code>-datadir</code> option to bitcoin-cli as to bitcoind. This will enable it to find the cookie file, but also potential other relevant changes you could have made to bitcoin.conf like rpcport. (I know you haven't, but this approach is compatible with those).</p>

CC BY-SA 4.0
2018-06-17T16:14:28.790Z
2018-06-17T16:14:28.790Z
Pieter Wuille
<p>Bitcoind is searching for the <code>.cookie</code> file in the configuration directory.</p>

<p>If you'd like to specify a path for the configuration that's not the default (i.e. In your hard drive), you can do so with the <code>-conf=/path/to/bitcoin.conf</code></p>

CC BY-SA 3.0
2018-01-27T21:20:43.507Z
I still get the same result. I'm updating the question to note that my bitcoin.conf file is completely empty.
Martin K
CC BY-SA 3.0
2018-01-27T15:24:45.577Z
2018-01-27T15:24:45.577Z
arshbot
<p>If this is a bug (it sounds like it is!) please open an issue for Bitcoin Core on the <a href="https://github.com/bitcoin/bitcoin/issues" rel="nofollow noreferrer">official Bitcoin Core repository issue page</a>.</p>

<p>Please specifically identify as much information in the issue you log as you have here in your question including:</p>

<p><strong>Version and Source</strong><br>
v0.xx.x downloaded from/compiled from</p>

<p><strong>Expected Operation</strong><br>
<code>bitcoind</code> should look in the <code>-datadir=</code> location for the RPC cookie.</p>

<p><strong>What Happens</strong><br>
<code>bitcoind</code> looks in the default location for the RPC cookie and RPC expects <code>bitcoin.conf</code> will be in the default location when checking for credentials.</p>

<p>Everything should be expected in the <code>-datadir=</code> location.</p>

<p>Setting <code>-rpccookiefile=</code> to the correct path matching the specified <code>-datadir=</code> location does not work.</p>

<p><strong>Steps to reproduce</strong><br>
<em>Most of your question and any other details.</em></p>

CC BY-SA 3.0
2018-01-28T01:00:21.023Z
Previous user with same issue found a workaround for their scenario: https://bitcoin.stackexchange.com/questions/53194/bitcoind-not-using-correct-directory-inspite-of-datadir-argument
Willtech
CC BY-SA 3.0
2018-01-28T00:23:09.637Z
2018-01-28T00:53:32.837Z
2018-01-28T00:53:32.837Z
Willtech
<p>On <strong>Elementary OS Loki 0.4.1</strong> I've downloaded and installed bitcoind as per the <a href="https://bitcoin.org/en/full-node#ubuntu-1610" rel="nofollow noreferrer">official guide from bitcoin.org</a> .</p>

<p>However, I in my case I don't have enough space on my internal SSD to store the whole blockchain, so I want to download it and maintain it on an external hooked up HDD. </p>

<p>When I run the <code>bitcoind -daemon -datadir=path_to_external_hdd_folder</code> the Bitcoin server starts up successfully and starts downloading the blockchain to that specified folder (In the logs I can see the height is growing and so is the size of the selected datadir which I passed in as an argument) </p>

<p>My problem is - when I try to run commands by running <code>bitcoin-cli getblockchaininfo</code> for example, I get the error:</p>

<pre><code>error: Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (/home/martin/.bitcoin/bitcoin.conf)
</code></pre>

<p>What's weird is that when I move the <code>.cookie</code> file from my external drive to <code>/home/martin/.bitcoin/bitcoin.conf</code> the commands start working. </p>

<p>This is a temporary solution though, I wouldn't like to move that file everytime I startup the bitcoin server. </p>

<p>Do I maybe need to pass in an extra argument to <code>bitcoind -daemon</code>?</p>

<p>I've tried passing <code>-rpccookiefile=path_to_cookie_file_on_External_hdd</code> to it but that didn't work.</p>

<p><em>Note:</em> My bitcoin.conf file is empty. </p>

<p><strong>UPDATE 1</strong>
I tried setting <code>-conf</code> when starting bitcoind but that didn't work either.</p>

CC BY-SA 3.0
2018-01-28T00:55:42.107Z
I have added an answer. Note that some of the parameters you have tried only accept a file input and will not accept a path.
Willtech
CC BY-SA 3.0
2018-01-28T00:59:10.063Z
Previous user with same issue found a workaround for their scenario: https://bitcoin.stackexchange.com/questions/53194/bitcoind-not-using-correct-directory-inspite-of-datadir-argument
Willtech
<bitcoin-core><bitcoind><client><full-node><bitcoin-cli>
Bitcoind running on external HDD trying to resolve cookie from default datadir
Martin K
# Bitcoind running on external HDD trying to resolve cookie from default datadir

(Asked by: username_0 on 2018-01-27)

On **Elementary OS Loki 0.4.1** I've downloaded and installed bitcoind as per the [official guide from bitcoin.org](https://bitcoin.org/en/full-node#ubuntu-1610) .

However, I in my case I don't have enough space on my internal SSD to store the whole blockchain, so I want to download it and maintain it on an external hooked up HDD.

When I run the `bitcoind -daemon -datadir=path_to_external_hdd_folder` the Bitcoin server starts up successfully and starts downloading the blockchain to that specified folder (In the logs I can see the height is growing and so is the size of the selected datadir which I passed in as an argument)

My problem is - when I try to run commands by running `bitcoin-cli getblockchaininfo` for example, I get the error:

```
error: Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (/home/username_0/.bitcoin/bitcoin.conf)

```

What's weird is that when I move the `.cookie` file from my external drive to `/home/username_0/.bitcoin/bitcoin.conf` the commands start working.

This is a temporary solution though, I wouldn't like to move that file everytime I startup the bitcoin server.

Do I maybe need to pass in an extra argument to `bitcoind -daemon`?

I've tried passing `-rpccookiefile=path_to_cookie_file_on_External_hdd` to it but that didn't work.

*Note:* My bitcoin.conf file is empty.

**UPDATE 1**
I tried setting `-conf` when starting bitcoind but that didn't work either.

**Tags:** bitcoin-core, bitcoind, client, full-node, bitcoin-cli

> **Comments:**
> **username_1**: I have added an answer. Note that some of the parameters you have tried only accept a file input and will not accept a path.  
> **username_1**: Previous user with same issue found a workaround for their scenario: https://bitcoin.stackexchange.com/questions/53194/bitcoind-not-using-correct-directory-inspite-of-datadir-argument  

---

## 3 answers

### Answer by username_2 on 2018-06-17. Score: 1

You need to pass the same `-datadir` option to bitcoin-cli as to bitcoind. This will enable it to find the cookie file, but also potential other relevant changes you could have made to bitcoin.conf like rpcport. (I know you haven't, but this approach is compatible with those).


---

### Answer by username_3 on 2018-01-27. Score: 0

Bitcoind is searching for the `.cookie` file in the configuration directory.

If you'd like to specify a path for the configuration that's not the default (i.e. In your hard drive), you can do so with the `-conf=/path/to/bitcoin.conf`

> **Comments:**
> **username_0**: I still get the same result. I'm updating the question to note that my bitcoin.conf file is completely empty.  

---

### Answer by username_1 on 2018-01-28. Score: 0

If this is a bug (it sounds like it is!) please open an issue for Bitcoin Core on the [official Bitcoin Core repository issue page](https://github.com/bitcoin/bitcoin/issues).

Please specifically identify as much information in the issue you log as you have here in your question including:

**Version and Source**  
v0.xx.x downloaded from/compiled from

**Expected Operation**  
`bitcoind` should look in the `-datadir=` location for the RPC cookie.

**What Happens**  
`bitcoind` looks in the default location for the RPC cookie and RPC expects `bitcoin.conf` will be in the default location when checking for credentials.

Everything should be expected in the `-datadir=` location.

Setting `-rpccookiefile=` to the correct path matching the specified `-datadir=` location does not work.

**Steps to reproduce**  
*Most of your question and any other details.*

> **Comments:**
> **username_1**: Previous user with same issue found a workaround for their scenario: https://bitcoin.stackexchange.com/questions/53194/bitcoind-not-using-correct-directory-inspite-of-datadir-argument  

---

