<p>I've had to do this, so I'll try to describe exactly what you need to do to get mining on testnet to work in a local setup. For our purposes, we'll have 2 instances of bitcoind running, the first set up to be a miner, the second as a peer.</p>

<p>First, create two directories, one for the miner, the other for the peer:</p>

<pre><code>$ mkdir 1
$ mkdir 2
</code></pre>

<p>Now create this file in the 1 directory:</p>

<pre><code>$ &lt;your favorite editor&gt; 1/bitcoin.conf
</code></pre>

<p>Here are the contents of the file:</p>

<pre><code>testnet=1
irc=0
dnsseed=0
upnp=0
listen=1
checkpoints=0
server=1
rpcuser=test
rpcpassword=test
rpcallowip=127.0.0.1
port=20000
rpcport=20001
</code></pre>

<p>Now go and make the same file for the 2 directory</p>

<pre><code>$ &lt;your favorite editor&gt; 2/bitcoin.conf
</code></pre>

<p>Contents:</p>

<pre><code>testnet=1
irc=0
dnsseed=0
upnp=0
listen=0
checkpoints=0
connect=127.0.0.1:20000
rpcuser=test
rpcpassword=test
port=20010
rpcport=20011
</code></pre>

<p>Run the first instance:</p>

<pre><code>$ bitcoind -datadir=1 -daemon
</code></pre>

<p>Run the second instance:</p>

<pre><code>$ bitcoind -datadir=2 -daemon
</code></pre>

<p>You can check to see if everything is up and running by using bitcoin-cli:</p>

<pre><code>$ bitcoin-cli -datadir=1 getinfo
</code></pre>

<p>Blocks should be 0 until you mine something.</p>

<p>If you have mining hardware, you can now mine by connecting to 127.0.0.1:20001 with the user/pass of test/test. The actual command to connect will differ based on the mining software you use, but for bfgminer, it would be something like:</p>

<pre><code>$ bfgminer -o http://127.0.0.1:20001 -O test:test --generate-to &lt;a testnet address&gt; --no-longpoll -S all
</code></pre>

<p>Note that CPU mining takes several hours to find a block from my experience.</p>

CC BY-SA 3.0
2015-10-29T18:26:55.650Z
2015-10-29T18:26:55.650Z
Jimmy Song
<p>I created a testnet for mining using several ports in a single machine. However I see that the source codes [CAddrInfo, CAddr] are based on IP and not IP||port. Is there an easy change to make it do mining across ports [under same IP] or this is simply not possible?</p>

CC BY-SA 3.0
2015-10-29T04:16:31.353Z
It sounds like what you *actually* want is regest.
Nick ODell
CC BY-SA 3.0
2015-10-29T04:20:35.110Z
@Something similar, but the problem is `regtest` does not support peer discovery right exactly as the `testnet` right ? For eg: If I start nodes A, B, C, D and E on different ports and make A connect to C, D, and E via `-addnode` and B to A, then will the peer discovery mechanism work to form connections between B and C,D,E and similarly for other nodes ?
bawejakunal
<bitcoind><testnet><port><miner-configuration>
How to set up a private bitcoin network with mining on a single machine?
bawejakunal
# How to set up a private bitcoin network with mining on a single machine?

(Asked by: username_0 on 2015-10-29)

I created a testnet for mining using several ports in a single machine. However I see that the source codes [CAddrInfo, CAddr] are based on IP and not IP||port. Is there an easy change to make it do mining across ports [under same IP] or this is simply not possible?

**Tags:** bitcoind, testnet, port, miner-configuration

> **Comments:**
> **username_1**: It sounds like what you *actually* want is regest.  
> **username_0**: @Something similar, but the problem is `regtest` does not support peer discovery right exactly as the `testnet` right ? For eg: If I start nodes A, B, C, D and E on different ports and make A connect to C, D, and E via `-addnode` and B to A, then will the peer discovery mechanism work to form connections between B and C,D,E and similarly for other nodes ?  

---

## 1 answers

### Answer by username_2 on 2015-10-29. Score: 3

I've had to do this, so I'll try to describe exactly what you need to do to get mining on testnet to work in a local setup. For our purposes, we'll have 2 instances of bitcoind running, the first set up to be a miner, the second as a peer.

First, create two directories, one for the miner, the other for the peer:

```
$ mkdir 1
$ mkdir 2

```

Now create this file in the 1 directory:

```
$ <your favorite editor> 1/bitcoin.conf

```

Here are the contents of the file:

```
testnet=1
irc=0
dnsseed=0
upnp=0
listen=1
checkpoints=0
server=1
rpcuser=test
rpcpassword=test
rpcallowip=127.0.0.1
port=20000
rpcport=20001

```

Now go and make the same file for the 2 directory

```
$ <your favorite editor> 2/bitcoin.conf

```

Contents:

```
testnet=1
irc=0
dnsseed=0
upnp=0
listen=0
checkpoints=0
connect=127.0.0.1:20000
rpcuser=test
rpcpassword=test
port=20010
rpcport=20011

```

Run the first instance:

```
$ bitcoind -datadir=1 -daemon

```

Run the second instance:

```
$ bitcoind -datadir=2 -daemon

```

You can check to see if everything is up and running by using bitcoin-cli:

```
$ bitcoin-cli -datadir=1 getinfo

```

Blocks should be 0 until you mine something.

If you have mining hardware, you can now mine by connecting to 127.0.0.1:20001 with the user/pass of test/test. The actual command to connect will differ based on the mining software you use, but for bfgminer, it would be something like:

```
$ bfgminer -o http://127.0.0.1:20001 -O test:test --generate-to <a testnet address> --no-longpoll -S all

```

Note that CPU mining takes several hours to find a block from my experience.


---

