<p>Firstly, command line arguments always override the config files.</p>
<p>Secondly, if you specify a config file using <code>-conf</code>, the default config file in the datadir will not be used - only the config file you specified will be used.</p>
<p>Thirdly, if you don't specify a <code>-datadir</code> as a command line argument, the bitcoin.conf in the default datadir location will be loaded. If that config file specifies a different datadir be used, that chosen datadir will be used for blocks, wallets, etc. but no config file will be loaded from it. The config file in the chosen datadir will only be used if you load Bitcoin with the <code>-datadir</code> arg set on the command line so that it looks in that datadir <em>first</em>.</p>
<p>Generally, if there is a conflict between two options, the first one will win. That means an option set in the main conf file will take precedence over one set in an <code>includeconf</code> file. You can use multiple <code>includeconf</code> augments in the main config file but they can't be recursive - you can't use <code>includeconf</code> inside a file that was included using <code>includeconf</code>.</p>
<p>The exception to this is that options declared network-specific (e.g. <code>[main]</code>) will take precedence over non-network-specific options, even if declared later.</p>
<p><a href="https://github.com/bitcoin/bitcoin/blob/853ac47705c8abd9b8bda2da59eb043d9591491c/doc/bitcoin-conf.md" rel="nofollow noreferrer">Source</a></p>

CC BY-SA 4.0
2021-12-19T13:50:12.497Z
Thank you. Regarding the conflict of keys: If a key is behind the `datadir` key as well as in the config file of the `datadir` directory, the key in the main config file will still be the first, right? So the order of priority is _main config_, _datadir config (if `-conf` wasn't used)_, _includeconf config_, ..., right? Also can I use `includeconf` in the config file at `datadir` as well?
Martin Braun
CC BY-SA 4.0
2021-12-19T20:40:33.490Z
I've updated my answer to answer your followups.
meshcollider
CC BY-SA 4.0
2021-12-19T10:41:30.647Z
2021-12-20T01:11:57.513Z
2021-12-20T01:11:57.513Z
meshcollider
<p>My main <code>bitcoin.conf</code> is located in the AppData. Setting the <code>datadir</code> in it or via argument allows me to let the daemon/qt load another <code>bitcoin.conf</code> that is located in the DataDir. I can also change the main <code>bitcoin.conf</code> by setting the <code>conf</code> via argument and I can also specify <code>includeconf</code> in the config to load another config file.</p>
<p>I'd like to know how the priority will be when using all of the above features on conflicting keys as well as if merging is done and if so, how.</p>
<p>For instance: Which of the values will be used if I define its key in the main config as well as in the config at the <code>datadir</code> and even in a config that was included using <code>includeconf</code>? Is it also possible to use <code>includeconf</code> twice or more times to load more than one additional configuration?</p>
<p>What if I use <code>includeconf</code> in the config of the <code>datadir</code> and in the main <code>conf</code> and both files also contain conflicting keys? Will there be any merging at all?</p>

<bitcoin.conf>
bitcoin.conf priority on merging and conflicting keys?
Martin Braun
# bitcoin.conf priority on merging and conflicting keys?

(Asked by: username_0 on 2021-12-18)

My main `bitcoin.conf` is located in the AppData. Setting the `datadir` in it or via argument allows me to let the daemon/qt load another `bitcoin.conf` that is located in the DataDir. I can also change the main `bitcoin.conf` by setting the `conf` via argument and I can also specify `includeconf` in the config to load another config file.

I'd like to know how the priority will be when using all of the above features on conflicting keys as well as if merging is done and if so, how.

For instance: Which of the values will be used if I define its key in the main config as well as in the config at the `datadir` and even in a config that was included using `includeconf`? Is it also possible to use `includeconf` twice or more times to load more than one additional configuration?

What if I use `includeconf` in the config of the `datadir` and in the main `conf` and both files also contain conflicting keys? Will there be any merging at all?

**Tags:** bitcoin.conf


---

## 1 answers

### Answer by username_1 on 2021-12-19. Score: 2 | Accepted answer

Firstly, command line arguments always override the config files.

Secondly, if you specify a config file using `-conf`, the default config file in the datadir will not be used - only the config file you specified will be used.

Thirdly, if you don't specify a `-datadir` as a command line argument, the bitcoin.conf in the default datadir location will be loaded. If that config file specifies a different datadir be used, that chosen datadir will be used for blocks, wallets, etc. but no config file will be loaded from it. The config file in the chosen datadir will only be used if you load Bitcoin with the `-datadir` arg set on the command line so that it looks in that datadir *first*.

Generally, if there is a conflict between two options, the first one will win. That means an option set in the main conf file will take precedence over one set in an `includeconf` file. You can use multiple `includeconf` augments in the main config file but they can't be recursive - you can't use `includeconf` inside a file that was included using `includeconf`.

The exception to this is that options declared network-specific (e.g. `[main]`) will take precedence over non-network-specific options, even if declared later.

[Source](https://github.com/bitcoin/bitcoin/blob/853ac47705c8abd9b8bda2da59eb043d9591491c/doc/bitcoin-conf.md)

> **Comments:**
> **username_0**: Thank you. Regarding the conflict of keys: If a key is behind the `datadir` key as well as in the config file of the `datadir` directory, the key in the main config file will still be the first, right? So the order of priority is _main config_, _datadir config (if `-conf` wasn't used)_, _includeconf config_, ..., right? Also can I use `includeconf` in the config file at `datadir` as well?  
> **username_1**: I've updated my answer to answer your followups.  

---

