<p>You can pass the <code>-rpcport</code> flag to bitcoin-cli to specify which node to connect to when running multiple on the same machine.</p>

CC BY-SA 4.0
2018-11-12T09:21:05.293Z
2018-11-12T09:21:05.293Z
Raghav Sood
<p>I have bitcoin testnet3, mainnet, regtest both running in the same server, I can interactive with them by curl, because the ports are different, but when comes to bitcoin-cli how can I specific the network I want interactive with?</p>

<p>I get below error:</p>

<pre><code>$ bitcoin-cli -regtest setgenerate true 101  # I want use regtest
Error: Invalid combination of -regtest and -testnet.
</code></pre>

CC BY-SA 4.0
2018-11-12T08:47:25.517Z
Does your `bitcoin.conf` file contain a line `testnet=1` ?
Pieter Wuille
CC BY-SA 4.0
2018-11-14T14:13:16.183Z
yes, for testnet testnet=1 is on
Shiming
CC BY-SA 4.0
2018-11-14T17:31:57.160Z
So `bitcoin-cli` is combining the options from the command line and the config file, and sees both which are in conflict with eachother.
Pieter Wuille
<testnet>
how to differentiate bitcoin-cli command when have testnet & mainnet both running
Shiming
# how to differentiate bitcoin-cli command when have testnet & mainnet both running

(Asked by: username_0 on 2018-11-12)

I have bitcoin testnet3, mainnet, regtest both running in the same server, I can interactive with them by curl, because the ports are different, but when comes to bitcoin-cli how can I specific the network I want interactive with?
I get below error:
$ bitcoin-cli -regtest setgenerate true 101  # I want use regtest
Error: Invalid combination of -regtest and -testnet.

**Tags:** testnet

> **Comments:**
> **username_1**: Does your `bitcoin.conf` file contain a line `testnet=1` ?  
> **username_0**: yes, for testnet testnet=1 is on  
> **username_1**: So `bitcoin-cli` is combining the options from the command line and the config file, and sees both which are in conflict with eachother.  

---

## 1 answers

### Answer by username_2 on 2018-11-12. Score: 2

You can pass the `-rpcport` flag to bitcoin-cli to specify which node to connect to when running multiple on the same machine.


---

