<p>It appears that Fred Tingey's answer was mostly correct, but contained incorrect port numbers in the samples he provided. If someone were to copy and paste it all it would not have worked correctly.</p>

<p>I've modified his answer, it is awaiting peer review.</p>

<p>The use of Ubuntu, Docker and VirtualBox shouldn't affect your ability to configure regtest. </p>

<p>You may have problems connecting from the host to the guest, if you do I suggest perhaps asking questions on superuser or ubuntu exchanges instead.</p>

<p>Hope that helps!</p>

<p>=== Here's the edited version:</p>

<p>In order to run multiple nodes in <a href="https://bitcoin.org/en/developer-examples#regtest-mode" rel="nofollow noreferrer">regtest mode</a> on a single machine you will need to sandbox each node. </p>

<p>In this example I have three nodes, they are named Alice, Bob and Cory. Since Bitcoin is a Peer/Mesh network, my goal is to connect each nodes so that changes made to Cory are ultimately visible to Bob (without necessarily requiring a direct connection between the two.)</p>

<h2>Step 1: Create folders for each node.</h2>

<p>These folders will contain our data and configs for each node. The names are not important, they can be renamed later, so you can name them "Alice", "Bob" and "Cory" for now. Remember where you create them, you will need their paths for Step 3 below.</p>

<h2>Step 2: In each folder, create a <a href="https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File" rel="nofollow noreferrer">bitcoin.conf</a> file</h2>

<p>In the config files Alice will be configured to connect to Cory, and Bob will be configured to connect to Alice. In addition to configuring outbound connections, this is also where we specify <code>regtest=1</code> and <code>server=1</code> settings.</p>

<h3>bitcoin.conf for <em>Alice</em></h3>

<p><code>regtest=1
server=1
 # Alice connects to Cory
connect=localhost:18333</code></p>

<h3>bitcoin.con for <em>Bob</em></h3>

<p><code>regtest=1
server=1
 # Bob connects to Alice
connect=localhost:18444</code></p>

<h3>bitcoin.conf for <em>Cory</em></h3>

<p><code>regtest=1
server=1
 # Cory connects to nobody
</code></p>

<h2>Step 3: Start each node.</h2>

<p>Note each node must have a different port number since only one node can bind to a port number at any time.</p>

<ul>
<li>Alice on port 18444</li>
<li>Bob on port 18555</li>
<li>Cory on port 18333</li>
</ul>

<p>You can choose your own port numbers of course, just be careful not to use a port number that is already in use by something else.</p>

<p>The command-line options will tell bitcoin what port number to use, where to store data, and where to find its config file:</p>

<h3>Cory:</h3>

<p><code>"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Cory\bitcoin.conf" -datadir="C:\Cory" -port=18333 -rpcport=8333</code></p>

<h3>Bob:</h3>

<p><code>"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Bob\bitcoin.conf" -datadir="C:\Bob" -port=18555 -rpcport=8555</code></p>

<h3>Alice:</h3>

<p><code>"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Alice\bitcoin.conf" -datadir="C:\Alice" -port=18444 -rpcport=8444</code></p>

<p>This will launch three instances of the Bitcoin Client, and the folders for each node will begin to initialize with regtest data.</p>

<h2>Step 4: Testing</h2>

<p>You can use the <code>Help-&gt;Debug Window-&gt;Console</code> option to interactively execute commands on any of the nodes. For example, you can mine 101 blocks with the following bitcoin console command:</p>

<p><code>setgenerate true 101</code></p>

<p>You should (after a few seconds) then have been awarded coins.  </p>

<p>These mining activities result in <a href="https://bitcoin.org/en/developer-guide#transaction-data" rel="nofollow noreferrer">coinbase transactions</a> - and only the last one of 50 BTC is available to spend. Now you can send some BTC to one of the other nodes.  After a bit more mining such a transaction will be <a href="https://en.bitcoin.it/wiki/Confirmation" rel="nofollow noreferrer">confirmed</a>.</p>

<p>You can also use the console commands <code>getpeerinfo</code> and <code>getinfo</code> to check the network is set up correctly.  One of them (Core wit port=18333) should have 'sync=true' in its peerinfo output, and all nodes should have the same "block height" regardless of which node is used for mining.</p>

CC BY-SA 3.0
2015-07-12T23:32:05.010Z
you don't need the -conf arguments btw... at least on linux. And you will need to add -rpcport=XXX to deconflict the rpc ports
DrEntropy
CC BY-SA 3.0
2017-01-26T22:52:01.303Z
You have to use `-listen=1` if you're setting `-connect` otherwise it won't accept incoming connections.
instagibbs
CC BY-SA 3.0
2017-11-04T16:32:40.017Z
you have 2 Bobs in command line examples
whatever
CC BY-SA 3.0
2015-02-12T14:50:49.040Z
2017-11-04T20:19:40.540Z
2017-11-04T20:19:40.540Z
wilson0x4d
<p>I am getting into Bitcoin development and it seems that bitcoin <a href="https://bitcoin.org/en/developer-examples#regtest-mode" rel="nofollow noreferrer">regtest mode</a> is perfect for testing our applications. </p>

<p>I am trying to create a network, following <a href="https://bitcoin.stackexchange.com/questions/28107/bitcoin-is-not-connected-in-regtest-mode/30697#30697">Fred Tingey's answer</a> but, unfortunately, it's not working. </p>

<p>I need suggestions, what information can I provide?
I am trying to use docker, but I have to first create 64-bit Ubuntu machine.
Thanks</p>

CC BY-SA 3.0
2015-02-12T13:49:31.147Z
Sure: [link](http://bitcoin.stackexchange.com/questions/28107/bitcoin-is-not-connected-in-regtest-mode)
sbaha88
CC BY-SA 3.0
2015-02-12T13:50:23.503Z
I think I am not properly creating additional data directories. I can't connect to the network, the connection times out. @ShaunWilson
sbaha88
CC BY-SA 3.0
2015-02-12T13:58:27.800Z
Well the instructions in Fred's answer appear to be mostly correct, he does seem to list inconsistent port numbers. I'll see if i can clean it up.
wilson0x4d
CC BY-SA 3.0
2015-02-12T14:03:09.067Z
Thanks a lot. What I am struggling with is how to test if the network is working properly? Also, to create additional directories, is it just copy and paste? @ShaunWilson
sbaha88
CC BY-SA 3.0
2015-02-12T14:44:35.760Z
I cleaned up his answer, but it'll take a while for peer review to catch up to it. 

Yes, you can simply copy/paste folders to create more nodes.

Once they are running and connected you can use the command-line interface to issue commands like `getpeerinfo`, for example http://sourceforge.net/p/bitcoin/mailman/message/32012030/
wilson0x4d
CC BY-SA 3.0
2015-02-12T14:48:11.267Z
Can you also post your edited answer here please? @ShaunWilson
sbaha88
<bitcoind><regtest>
Is it possible to create bitcoind regtest network on Ubuntu (which itself is on Virtualbox)?
sbaha88
# Is it possible to create bitcoind regtest network on Ubuntu (which itself is on Virtualbox)?

(Asked by: username_0 on 2015-02-12)

I am getting into Bitcoin development and it seems that bitcoin [regtest mode](https://bitcoin.org/en/developer-examples#regtest-mode) is perfect for testing our applications.

I am trying to create a network, following [Fred Tingey's answer](https://bitcoin.stackexchange.com/questions/28107/bitcoin-is-not-connected-in-regtest-mode/30697#30697) but, unfortunately, it's not working.

I need suggestions, what information can I provide?
I am trying to use docker, but I have to first create 64-bit Ubuntu machine.
Thanks

**Tags:** bitcoind, regtest

> **Comments:**
> **username_0**: Sure: [link](http://bitcoin.stackexchange.com/questions/28107/bitcoin-is-not-connected-in-regtest-mode)  
> **username_0**: I think I am not properly creating additional data directories. I can't connect to the network, the connection times out. @ShaunWilson  
> **username_1**: Well the instructions in Fred's answer appear to be mostly correct, he does seem to list inconsistent port numbers. I'll see if i can clean it up.  
> **username_0**: Thanks a lot. What I am struggling with is how to test if the network is working properly? Also, to create additional directories, is it just copy and paste? @ShaunWilson  
> **username_1**: I cleaned up his answer, but it'll take a while for peer review to catch up to it.   Yes, you can simply copy/paste folders to create more nodes.  Once they are running and connected you can use the command-line interface to issue commands like `getpeerinfo`, for example http://sourceforge.net/p/bitcoin/mailman/message/32012030/  
> **username_0**: Can you also post your edited answer here please? @ShaunWilson  

---

## 1 answers

### Answer by username_1 on 2015-02-12. Score: 7

It appears that Fred Tingey's answer was mostly correct, but contained incorrect port numbers in the samples he provided. If someone were to copy and paste it all it would not have worked correctly.

I've modified his answer, it is awaiting peer review.

The use of Ubuntu, Docker and VirtualBox shouldn't affect your ability to configure regtest.

You may have problems connecting from the host to the guest, if you do I suggest perhaps asking questions on superuser or ubuntu exchanges instead.

Hope that helps!

=== Here's the edited version:

In order to run multiple nodes in [regtest mode](https://bitcoin.org/en/developer-examples#regtest-mode) on a single machine you will need to sandbox each node.

In this example I have three nodes, they are named Alice, Bob and Cory. Since Bitcoin is a Peer/Mesh network, my goal is to connect each nodes so that changes made to Cory are ultimately visible to Bob (without necessarily requiring a direct connection between the two.)

## Step 1: Create folders for each node.

These folders will contain our data and configs for each node. The names are not important, they can be renamed later, so you can name them "Alice", "Bob" and "Cory" for now. Remember where you create them, you will need their paths for Step 3 below.

## Step 2: In each folder, create a [bitcoin.conf](https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File) file

In the config files Alice will be configured to connect to Cory, and Bob will be configured to connect to Alice. In addition to configuring outbound connections, this is also where we specify `regtest=1` and `server=1` settings.

### bitcoin.conf for *Alice*

`regtest=1
server=1
# Alice connects to Cory
connect=localhost:18333`

### bitcoin.con for *Bob*

`regtest=1
server=1
# Bob connects to Alice
connect=localhost:18444`

### bitcoin.conf for *Cory*

`regtest=1
server=1
# Cory connects to nobody`

## Step 3: Start each node.

Note each node must have a different port number since only one node can bind to a port number at any time.

* Alice on port 18444
* Bob on port 18555
* Cory on port 18333

You can choose your own port numbers of course, just be careful not to use a port number that is already in use by something else.

The command-line options will tell bitcoin what port number to use, where to store data, and where to find its config file:

### Cory:

`"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Cory\bitcoin.conf" -datadir="C:\Cory" -port=18333 -rpcport=8333`

### Bob:

`"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Bob\bitcoin.conf" -datadir="C:\Bob" -port=18555 -rpcport=8555`

### Alice:

`"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf="C:\Alice\bitcoin.conf" -datadir="C:\Alice" -port=18444 -rpcport=8444`

This will launch three instances of the Bitcoin Client, and the folders for each node will begin to initialize with regtest data.

## Step 4: Testing

You can use the `Help->Debug Window->Console` option to interactively execute commands on any of the nodes. For example, you can mine 101 blocks with the following bitcoin console command:

`setgenerate true 101`

You should (after a few seconds) then have been awarded coins.

These mining activities result in [coinbase transactions](https://bitcoin.org/en/developer-guide#transaction-data) - and only the last one of 50 BTC is available to spend. Now you can send some BTC to one of the other nodes. After a bit more mining such a transaction will be [confirmed](https://en.bitcoin.it/wiki/Confirmation).

You can also use the console commands `getpeerinfo` and `getinfo` to check the network is set up correctly. One of them (Core wit port=18333) should have 'sync=true' in its peerinfo output, and all nodes should have the same "block height" regardless of which node is used for mining.

> **Comments:**
> **username_2**: you don't need the -conf arguments btw... at least on linux. And you will need to add -rpcport=XXX to deconflict the rpc ports  
> **username_3**: You have to use `-listen=1` if you're setting `-connect` otherwise it won't accept incoming connections.  
> **username_4**: you have 2 Bobs in command line examples  

---

