<p>If anyone is looking to connect to a RegTestnet using bitcoinJ here are the step on mac:</p>

<p>I used a docker image to setup the bitcoin network.</p>

<p><a href="https://github.com/freewil/bitcoin-testnet-box" rel="nofollow noreferrer">https://github.com/freewil/bitcoin-testnet-box</a></p>

<p>run this docker image using this command:</p>

<pre><code>docker run -t -i -p 19001:19001 -p 19011:19011 -p 19000:19000 freewil/bitcoin-testnet-box
</code></pre>

<p>When you run this docker image it will start 2 bitcoin nodes. </p>

<p>Node 1 will listen to bitcoin node connections on port 19000 and for rpc connections on port 19001.</p>

<p>Node 2 is not listening to bitcoin node connections. Node 2 is connected to node 1.</p>

<p>Now using the port forwarding settings in Virtual Box forward the container port 19000 to your host machine port 19000.</p>

<p>Now you can connect to Node 1 from any machine in your local network (wifi network) using the address your-machine-local-ip:19000</p>

<p>Here your local machine ip is the ip address of your laptop in your local network. In mac you can find it out from network preferences.</p>

<p>To connect to Node 1 from bitcoinj use this:</p>

<pre><code>mParams = RegTestParams.get();
.
.
// define how to connect based on network params
if (mParams == RegTestParams.get()) {
    try {
        PeerAddress pa = new PeerAddress(mParams, InetAddress.getByName("&lt;your-machine-local-ip&gt;"), 19000);
        mKit.setPeerNodes(pa);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
}
</code></pre>

CC BY-SA 3.0
2016-11-03T06:30:56.877Z
2016-11-03T06:30:56.877Z
theguru42
<p>Anyone knows how to connect to (or even possible) a remote "-regtest" server?
I have managed to setup the -regtest daemon, but still trying to figure out how to connect to it using BitCoinJ client.</p>

<p>===== Update ======</p>

<p>Just in-case someone here has the same query, I've managed to connect to the remote -regtest, I can now download the blockchain and perform RPC using BitCoinJ</p>

<ol>
<li><p>Just follow the bitcoin example to setup the bitcoind. (I ran using bitcoind -regtest -daemon)</p></li>
<li><p>In the BitcoinJ code, use the REG_TEST_NET, and add your remote -regtest server's IP to BitCoinJ's PeerGroup object using</p></li>
</ol>

<p>peerGroup.addAddress(InetAddress.getByName(your-remote-ip));</p>

<ol start="3">
<li>in the bitcoin.conf, I set the additional following attributes
server=1
rpcport=18444</li>
</ol>

CC BY-SA 3.0
2015-07-15T06:04:27.370Z
Just in-case someone here has the same query, I've managed to connect to the remote -regtest.
cozytrony
<bitcoind><bitcoinj><regtest>
Connecting to a bitcoind in "-regtest daemon" mode remotely from another node (e.g. BitCoinJ)
cozytrony
# Connecting to a bitcoind in "-regtest daemon" mode remotely from another node (e.g. BitCoinJ)

(Asked by: username_0 on 2015-07-14)

Anyone knows how to connect to (or even possible) a remote "-regtest" server?
I have managed to setup the -regtest daemon, but still trying to figure out how to connect to it using BitCoinJ client.

===== Update ======

Just in-case someone here has the same query, I've managed to connect to the remote -regtest, I can now download the blockchain and perform RPC using BitCoinJ

1. Just follow the bitcoin example to setup the bitcoind. (I ran using bitcoind -regtest -daemon)
2. In the BitcoinJ code, use the REG\_TEST\_NET, and add your remote -regtest server's IP to BitCoinJ's PeerGroup object using

peerGroup.addAddress(InetAddress.getByName(your-remote-ip));

3. in the bitcoin.conf, I set the additional following attributes
   server=1
   rpcport=18444

**Tags:** bitcoind, bitcoinj, regtest

> **Comments:**
> **username_0**: Just in-case someone here has the same query, I've managed to connect to the remote -regtest.  

---

## 1 answers

### Answer by username_1 on 2016-11-03. Score: 2

If anyone is looking to connect to a RegTestnet using bitcoinJ here are the step on mac:

I used a docker image to setup the bitcoin network.

<https://github.com/freewil/bitcoin-testnet-box>

run this docker image using this command:

```
docker run -t -i -p 19001:19001 -p 19011:19011 -p 19000:19000 freewil/bitcoin-testnet-box

```

When you run this docker image it will start 2 bitcoin nodes.

Node 1 will listen to bitcoin node connections on port 19000 and for rpc connections on port 19001.

Node 2 is not listening to bitcoin node connections. Node 2 is connected to node 1.

Now using the port forwarding settings in Virtual Box forward the container port 19000 to your host machine port 19000.

Now you can connect to Node 1 from any machine in your local network (wifi network) using the address your-machine-local-ip:19000

Here your local machine ip is the ip address of your laptop in your local network. In mac you can find it out from network preferences.

To connect to Node 1 from bitcoinj use this:

```
mParams = RegTestParams.get();
.
.
// define how to connect based on network params
if (mParams == RegTestParams.get()) {
    try {
        PeerAddress pa = new PeerAddress(mParams, InetAddress.getByName("<your-machine-local-ip>"), 19000);
        mKit.setPeerNodes(pa);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
}

```


---

