user-1: I run node 1 using this command:
bitcoind -port=2222 -datadir=/home/prayank/node1 -conf=/home/prayank/node1/bitcoin.conf -regtest=1 -rpcport=18666 -rpcuser=rpcuser -rpcpassword=rpcpass -bind=127.0.0.1

and node 2 with:
bitcoind -port=3333 -datadir=/home/prayank/node2 -conf=/home/prayank/node2/bitcoin.conf -regtest=1 -rpcport=18777 -rpcuser=rpcuser -rpcpassword=rpcpass -connect=127.0.0.1:2222


Why is 18445 port used to bind when 2222 was mentioned in -bind while running bitcoind (node 1)?

2022-01-21T14:31:51Z Bound to 127.0.0.1:2222
2022-01-21T14:31:51Z Bound to 127.0.0.1:18445


Manual outbound connection was successful however I want to do this automatically. How can I run a node 3 which discovers one of these nodes and creates an outbound connection automatically (node 2)?

2022-01-21T14:34:06Z New outbound peer connected: version: 70016, blocks=110, peer=0 (manual)


user208: 
Why is 18445 port used to bind when 2222 was mentioned in -bind while running bitcoind (node 1)?

When torcontrol is enabled, Bitcoin Core will listen on two separate ports by default: one for incoming connections from the public network, and one for incoming connections from tor. Using two separate ports helps Bitcoin Core distinguish which connections are tor connections and which ones aren't.
You can override the port for incoming Tor connections too: -bind=127.0.0.1:2223=onion would listen on port 2223 for those (and tell tor to forward incoming tor connections there).

How can I run a node 3 which discovers one of these nodes and creates an outbound connection automatically (node 2)?

Automatic connections are only for connecting to publicly reachable nodes. Unless you expose your 127.0.0.1:2222 port somehow to the Internet, the automatic connection mechanism doesn't apply here. Even if it is, that's probably not what you want.

-1: <p>I run node 1 using this command:</p>
<pre><code>bitcoind -port=2222 -datadir=/home/prayank/node1 -conf=/home/prayank/node1/bitcoin.conf -regtest=1 -rpcport=18666 -rpcuser=rpcuser -rpcpassword=rpcpass -bind=127.0.0.1
</code></pre>
<p>and node 2 with:</p>
<pre><code>bitcoind -port=3333 -datadir=/home/prayank/node2 -conf=/home/prayank/node2/bitcoin.conf -regtest=1 -rpcport=18777 -rpcuser=rpcuser -rpcpassword=rpcpass -connect=127.0.0.1:2222
</code></pre>
<ol>
<li>Why is 18445 port used to bind when 2222 was mentioned in <code>-bind</code> while running bitcoind (node 1)?</li>
</ol>
<pre><code>2022-01-21T14:31:51Z Bound to 127.0.0.1:2222
2022-01-21T14:31:51Z Bound to 127.0.0.1:18445
</code></pre>
<ol start="2">
<li>Manual outbound connection was successful however I want to do this automatically. How can I run a node 3 which discovers one of these nodes and creates an outbound connection automatically (node 2)?</li>
</ol>
<pre><code>2022-01-21T14:34:06Z New outbound peer connected: version: 70016, blocks=110, peer=0 (manual)
</code></pre>
 208: <blockquote>
<p>Why is 18445 port used to bind when 2222 was mentioned in -bind while running bitcoind (node 1)?</p>
</blockquote>
<p>When torcontrol is enabled, Bitcoin Core will listen on two separate ports by default: one for incoming connections from the public network, and one for incoming connections from tor. Using two separate ports helps Bitcoin Core distinguish which connections are tor connections and which ones aren't.</p>
<p>You can override the port for incoming Tor connections too: <code>-bind=127.0.0.1:2223=onion</code> would listen on port 2223 for those (and tell tor to forward incoming tor connections there).</p>
<blockquote>
<p>How can I run a node 3 which discovers one of these nodes and creates an outbound connection automatically (node 2)?</p>
</blockquote>
<p>Automatic connections are only for connecting to publicly reachable nodes. Unless you expose your 127.0.0.1:2222 port somehow to the Internet, the automatic connection mechanism doesn't apply here. Even if it is, that's probably not what you want.</p>
