<p>Run bitcoin.exe with conf and datadir params
And set the configuration file with testnet=1</p>

CC BY-SA 4.0
2018-08-25T14:19:15.363Z
i saw the config and am aware of these settings. but not sure how to ensure that my live blockchain stays untouched
Sonic Soul
CC BY-SA 4.0
2018-08-25T16:58:06.290Z
By default the two networks will operate in different directories.
Pieter Wuille
CC BY-SA 4.0
2018-08-25T14:08:26.827Z
2018-08-25T14:08:26.827Z
Haddar Macdasi
<p>You can run both at the same time:</p>

<pre><code>$ bitcoind -daemon
$ bitcoind -testnet -daemon
</code></pre>

<p>Then you can issue commands on either using:  </p>

<pre><code>$ bitcoin-cli &lt;commmand&gt;
</code></pre>

<p>or</p>

<pre><code>$ bitcoin-cli -testnet &lt;command&gt;
</code></pre>

<p>The blockchains are stored in <code>./bitcoin/blocks</code> for mainnet and <code>/bitcoin/testnet3/blocks</code> for testnet.</p>

<p><strong>Update</strong>: With the <code>bitcoin.conf</code> updated in the question remove <code>rpcport=8332</code>, so it doesn't try to use the same port for mainnet and testnet RPC.</p>

<p><strong>Update 2</strong>: With 0.17 release, it is now possible for a single configuration file to set different options for different networks in <code>bitcoin.conf</code>:</p>

<pre><code>main.uacomment=bitcoin
test.uacomment=bitcoin-testnet
regtest.uacomment=regtest
</code></pre>

<p>For more information, see the <a href="https://bitcoincore.org/en/releases/0.17.0/" rel="noreferrer">0.17.0 Release Notes</a></p>

CC BY-SA 4.0
2018-08-25T21:02:50.007Z
$ bitcoin-cli getblockcount: 538439
Sonic Soul
CC BY-SA 4.0
2018-08-25T21:03:26.477Z
$ bitcoin-cli -testnet getblockcount: 538439
Sonic Soul
CC BY-SA 4.0
2018-08-25T21:03:59.453Z
looks like its going against main
Sonic Soul
CC BY-SA 4.0
2018-08-25T21:13:36.047Z
hmm i do see the testnet3 folder under bitcoin now ..
Sonic Soul
CC BY-SA 4.0
2018-08-25T21:23:14.040Z
Hmm. might be an issue with your `bitcoin.conf`
JBaczuk
CC BY-SA 4.0
2018-08-25T21:29:30.963Z
seeing this in debug.log 
2018-08-25 21:08:24 Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2018-08-25 21:08:24 Using 2 threads for script verification
2018-08-25 21:08:24 scheduler thread start
2018-08-25 21:08:24 Binding RPC on address :: port 8332 failed.
2018-08-25 21:08:24 Binding RPC on address 0.0.0.0 port 8332 failed.
2018-08-25 21:08:24 Unable to bind any endpoint for RPC server
2018-08-25 21:08:24 Error: Unable to start HTTP server. See debug log for details.
Sonic Soul
CC BY-SA 4.0
2018-08-25T21:38:49.230Z
You might want to restart the daemons using `$bitcoin-cli stop` and `$bitcoin-cli -testnet stop` and then start again.
JBaczuk
CC BY-SA 4.0
2018-08-26T13:38:18.200Z
hmm tried that  but keep seeing *Binding RPC on address 0.0.0.0 port 8332 failed.*
Sonic Soul
CC BY-SA 4.0
2018-08-26T14:51:52.290Z
Is something using that port?
JBaczuk
CC BY-SA 4.0
2018-08-26T15:08:48.687Z
so i set testnet=1 in bitcoin.conf which seems to work but now the main node is only running test i think. not sure if i can run both at the same time
Sonic Soul
CC BY-SA 4.0
2018-08-26T15:26:59.037Z
Clear that line. If you only put the flag in the command line you can run both.
JBaczuk
CC BY-SA 4.0
2018-08-26T15:59:28.713Z
thanks! good to know :) for some reason w/out the line testnet wasn't working for me though.. keep getting that error in debug.log
Sonic Soul
CC BY-SA 4.0
2018-08-26T16:34:04.017Z
Is it still not working? Would be helpful to post bitcoin.conf
JBaczuk
CC BY-SA 4.0
2018-08-26T21:30:48.473Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/82279/discussion-between-sonic-soul-and-jbaczuk).
Sonic Soul
CC BY-SA 4.0
2018-08-25T16:42:21.707Z
2018-11-11T16:12:44.010Z
2018-11-11T16:12:44.010Z
JBaczuk
<p>it took me 4 days to fully synchronize my node, but its finally running and i can create wallets etc..</p>

<p>I wanted to experiment with some transactions on testnet, so need to either change my config or create a separate instance. </p>

<p>But I don't want to lose my synchronized live node, so what's the best strategy to switch to testnet while still being able to switch back? </p>

<pre><code># [core]
datadir=/mnt/volume-nyc1-03/Bitcoin
dbcache=2000
txindex=1

# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Username for JSON-RPC connections
rpcuser=bitcoin
# Password for JSON-RPC connections
rpcpassword=sayblockchainonemoretime
rpcport=8332
rpcallowip=x.x.x.x/x (ip masked) 
# [wallet]
# Do not load the wallet and disable wallet RPC calls.
disablewallet=0
</code></pre>

<bitcoin-core><bitcoind><testnet><bitcoin-cli>
running live and test node simultaneously
Sonic Soul
# running live and test node simultaneously

(Asked by: username_0 on 2018-08-25)

it took me 4 days to fully synchronize my node, but its finally running and i can create wallets etc..

I wanted to experiment with some transactions on testnet, so need to either change my config or create a separate instance.

But I don't want to lose my synchronized live node, so what's the best strategy to switch to testnet while still being able to switch back?

```
# [core]
datadir=/mnt/volume-nyc1-03/Bitcoin
dbcache=2000
txindex=1

# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Username for JSON-RPC connections
rpcuser=bitcoin
# Password for JSON-RPC connections
rpcpassword=sayblockchainonemoretime
rpcport=8332
rpcallowip=x.x.x.x/x (ip masked) 
# [wallet]
# Do not load the wallet and disable wallet RPC calls.
disablewallet=0

```

**Tags:** bitcoin-core, bitcoind, testnet, bitcoin-cli


---

## 2 answers

### Answer by username_3 on 2018-08-25. Score: 10 | Accepted answer

You can run both at the same time:

```
$ bitcoind -daemon
$ bitcoind -testnet -daemon

```

Then you can issue commands on either using:

```
$ bitcoin-cli <commmand>

```

or

```
$ bitcoin-cli -testnet <command>

```

The blockchains are stored in `./bitcoin/blocks` for mainnet and `/bitcoin/testnet3/blocks` for testnet.

**Update**: With the `bitcoin.conf` updated in the question remove `rpcport=8332`, so it doesn't try to use the same port for mainnet and testnet RPC.

**Update 2**: With 0.17 release, it is now possible for a single configuration file to set different options for different networks in `bitcoin.conf`:

```
main.uacomment=bitcoin
test.uacomment=bitcoin-testnet
regtest.uacomment=regtest

```

For more information, see the [0.17.0 Release Notes](https://bitcoincore.org/en/releases/0.17.0/)

> **Comments:**
> **username_0**: $ bitcoin-cli getblockcount: 538439  
> **username_0**: $ bitcoin-cli -testnet getblockcount: 538439  
> **username_0**: looks like its going against main  
> **username_0**: hmm i do see the testnet3 folder under bitcoin now ..  
> **username_3**: Hmm. might be an issue with your `bitcoin.conf`  
> **username_0**: seeing this in debug.log  2018-08-25 21:08:24 Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements 2018-08-25 21:08:24 Using 2 threads for script verification 2018-08-25 21:08:24 scheduler thread start 2018-08-25 21:08:24 Binding RPC on address :: port 8332 failed. 2018-08-25 21:08:24 Binding RPC on address 0.0.0.0 port 8332 failed. 2018-08-25 21:08:24 Unable to bind any endpoint for RPC server 2018-08-25 21:08:24 Error: Unable to start HTTP server. See debug log for details.  
> **username_3**: You might want to restart the daemons using `$bitcoin-cli stop` and `$bitcoin-cli -testnet stop` and then start again.  
> **username_0**: hmm tried that  but keep seeing *Binding RPC on address 0.0.0.0 port 8332 failed.*  
> **username_3**: Is something using that port?  
> **username_0**: so i set testnet=1 in bitcoin.conf which seems to work but now the main node is only running test i think. not sure if i can run both at the same time  
> **username_3**: Clear that line. If you only put the flag in the command line you can run both.  
> **username_0**: thanks! good to know :) for some reason w/out the line testnet wasn't working for me though.. keep getting that error in debug.log  
> **username_3**: Is it still not working? Would be helpful to post bitcoin.conf  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/82279/discussion-between-username_0-username_0-and-username_3).  

---

### Answer by username_1 on 2018-08-25. Score: 0

Run bitcoin.exe with conf and datadir params
And set the configuration file with testnet=1

> **Comments:**
> **username_0**: i saw the config and am aware of these settings. but not sure how to ensure that my live blockchain stays untouched  
> **username_2**: By default the two networks will operate in different directories.  

---

