<p>No, bitcoin core does not expand environment variables in <code>bitcoin.conf</code>.</p>

<p>See <a href="https://github.com/bitcoin/bitcoin/blob/0.19/src/util/system.cpp#L812" rel="nofollow noreferrer">here</a> to see how options are parsed.</p>

<p>You can expand environment variables as arguments for <code>bitcoind</code>:</p>



<pre><code>$ bitcoind -rpcuser="$RPC_USERNAME" -rpcpassword="$RPC_PASSWORD"
</code></pre>

CC BY-SA 4.0
2020-01-29T05:45:59.940Z
2020-01-29T05:56:50.340Z
2020-01-29T05:56:50.340Z
ohmyfromage
<p>I would like to store my Bitcoin RPC passwords and usernames in environment variables, like:</p>

<blockquote>
<pre><code>rpcuser=$RPC_USER
rpcpassword=$RPC_PASSWORD
</code></pre>
</blockquote>

<p>Is this supported in bitcoin core? Can environmental variables be parsed from my bitcoin.conf file?</p>

CC BY-SA 3.0
2013-05-24T17:47:02.963Z
Very bad idea! Why should you do such a thing?
o0'.
CC BY-SA 3.0
2013-05-24T17:52:12.490Z
Why is it a bad idea?
alfetopito
CC BY-SA 3.0
2016-01-13T23:27:46.247Z
I don't think this is a bad idea, but I *do* think that this is an [XY Problem](http://xyproblem.info/).
Nick ODell
CC BY-SA 3.0
2017-03-19T20:29:51.667Z
This would be great to have. I use docker to host my bitcoin node and I would like to be able to have docker inject environment variables depending on production/dev etc. Have you found how to do this yet?
Mr_E
CC BY-SA 3.0
2017-04-17T18:10:35.063Z
It's been awhile. At the time, I ended up generating the config file with the values rather than using envvars, as I found no other way to do it.
alfetopito
<passphrase><bitcoin.conf>
Does bitcoin.conf expand environment variables?
alfetopito
# Does bitcoin.conf expand environment variables?

(Asked by: username_0 on 2013-05-24)

I would like to store my Bitcoin RPC passwords and usernames in environment variables, like:

rpcuser=$RPC_USER
rpcpassword=$RPC_PASSWORD


Is this supported in bitcoin core? Can environmental variables be parsed from my bitcoin.conf file?

**Tags:** passphrase, bitcoin.conf

> **Comments:**
> **username_1**: Very bad idea! Why should you do such a thing?  
> **username_0**: Why is it a bad idea?  
> **username_2**: I don't think this is a bad idea, but I *do* think that this is an [XY Problem](http://xyproblem.info/).  
> **username_3**: This would be great to have. I use docker to host my bitcoin node and I would like to be able to have docker inject environment variables depending on production/dev etc. Have you found how to do this yet?  
> **username_0**: It's been awhile. At the time, I ended up generating the config file with the values rather than using envvars, as I found no other way to do it.  

---

## 1 answers

### Answer by username_4 on 2020-01-29. Score: 3 | Accepted answer

No, bitcoin core does not expand environment variables in bitcoin.conf.
See here to see how options are parsed.
You can expand environment variables as arguments for bitcoind:
$ bitcoind -rpcuser="$RPC_USERNAME" -rpcpassword="$RPC_PASSWORD"


---

