<p>It seems to me that the ports aren't matching:</p>

<p>You've set your first node to <code>port=8333</code> and your second node to <code>port=8330</code>. However, you've called <code>addnode</code> with <code>…18332</code>. Maybe that's it?</p>

CC BY-SA 3.0
2017-04-04T09:45:30.220Z
2017-04-04T09:45:30.220Z
Murch
<p>I set up a small git repo which does this using docker: <a href="https://github.com/FreekPaans/bitcoin-multi-node-regtest" rel="nofollow noreferrer">https://github.com/FreekPaans/bitcoin-multi-node-regtest</a></p>

CC BY-SA 3.0
2018-04-11T07:25:51.510Z
2018-04-11T07:25:51.510Z
Freek
<p>I am trying to connect two local regtest nodes together. I am able to run one regtest node without any issues, and am also able to run the bitcoin-cli commands such as generate to create my own chain, however when I try to start a new node, I'm not able to connect them. This is what I do (sorry if there is a clear mistake). </p>

<pre><code>Run node 1
./src/bitcoind -regtest -port=8333 -rpcport=8332 -datadir=/Documents/node1data -conf=Bitcoin/bitcoin.conf

Run node 2 
./src/bitcoind -regtest -port=8330 -rpcport=8331 -datadir=/Documents/node2data -conf=/Bitcoin/bitcoin.conf
</code></pre>

<p>By now I seem to have two different chains, generating blocks on one node doesn't change the number of blocks in the other node. I would like to have these two nodes share a chain so that mining a block in one of the nodes updates the chain on both of them. However when I try to connect them using the following command: </p>

<pre><code>./src/bitcoin-cli -regtest -port=8333 -rpcport=8332 -rpcuser=user -rpcpassword=password addnode "http://127.0.0.1:18332" "add"
</code></pre>

<p>The rpc call to addnode displays no errors and if I run it again I get: "Error: Node already added"</p>

<p>After this call, the command </p>

<pre><code>./src/bitcoin-cli -regtest -port=8333 -rpcport=8332 -rpcuser=user -rpcpassword=password getconnectioncount
</code></pre>

<p>returns 0...</p>

<p>So, I see a lot of people using software such as dockers, etc. Why is this not working? Am I completely mistaken to think this could work, if so I would love to know where I'm failing. Ultimately, how can I achieve to have two or three nodes connected to each other? </p>

<p>Thanks in advance to anyone who reads my question. </p>

<json-rpc><testnet><nodes><regtest>
Connecting two local nodes in RegTest
omzy
# Connecting two local nodes in RegTest

(Asked by: username_0 on 2017-03-22)

I am trying to connect two local regtest nodes together. I am able to run one regtest node without any issues, and am also able to run the bitcoin-cli commands such as generate to create my own chain, however when I try to start a new node, I'm not able to connect them. This is what I do (sorry if there is a clear mistake).

```
Run node 1
./src/bitcoind -regtest -port=8333 -rpcport=8332 -datadir=/Documents/node1data -conf=Bitcoin/bitcoin.conf

Run node 2 
./src/bitcoind -regtest -port=8330 -rpcport=8331 -datadir=/Documents/node2data -conf=/Bitcoin/bitcoin.conf

```

By now I seem to have two different chains, generating blocks on one node doesn't change the number of blocks in the other node. I would like to have these two nodes share a chain so that mining a block in one of the nodes updates the chain on both of them. However when I try to connect them using the following command:

```
./src/bitcoin-cli -regtest -port=8333 -rpcport=8332 -rpcuser=user -rpcpassword=password addnode "http://127.0.0.1:18332" "add"

```

The rpc call to addnode displays no errors and if I run it again I get: "Error: Node already added"

After this call, the command

```
./src/bitcoin-cli -regtest -port=8333 -rpcport=8332 -rpcuser=user -rpcpassword=password getconnectioncount

```

returns 0...

So, I see a lot of people using software such as dockers, etc. Why is this not working? Am I completely mistaken to think this could work, if so I would love to know where I'm failing. Ultimately, how can I achieve to have two or three nodes connected to each other?

Thanks in advance to anyone who reads my question.

**Tags:** json-rpc, testnet, nodes, regtest


---

## 2 answers

### Answer by username_1 on 2017-04-04. Score: 3

It seems to me that the ports aren't matching:

You've set your first node to `port=8333` and your second node to `port=8330`. However, you've called `addnode` with `…18332`. Maybe that's it?


---

### Answer by username_2 on 2018-04-11. Score: 1

I set up a small git repo which does this using docker: <https://github.com/FreekPaans/bitcoin-multi-node-regtest>


---

