[bug]: btcd doesn't connect to all the peers configured with `addpeer=` (master)
Background
btcd seems to not bother connecting to all the peers configured with addpeer=, and also not connect to more than 2-3 peers.
Your environment
- version of
btcd: 9ff0780d - which operating system: EndeavourOS
config:
[Application Options]
prune=1536
addpeer=2a01:4f8:262:4bc4::2
addpeer=2603:3003:4eac:100:4e5f:e7a6:2059:91d8
addpeer=2600:1700:8b81:9810::48
addpeer=213.193.83.253
addpeer=208.65.166.25
addpeer=2607:5300:203:5b84::1
nolisten=1
addcheckpoint=901901:00000000000000000000274ee89ba9625a079859cbcd4b57a11999e24456ccf8
v2transport=1
rpcuser=uwuser
rpcpass=pawss
notls=1
limitfreerelay=0
maxorphantx=1000
sigcachemaxsize=100000
blockmaxweight=3996000
blockprioritysize=50000
logs:
2025-11-06 00:00:11.828 [INF] BTCD: Version 0.25.0-beta
2025-11-06 00:00:11.829 [INF] BTCD: Loading block database from '/home/____________/.btcd/data/mainnet/blocks_ffldb'
2025-11-06 00:00:12.000 [INF] BTCD: Block database loaded
2025-11-06 00:00:12.009 [INF] INDX: Committed filter index is enabled
2025-11-06 00:00:12.009 [INF] BTCD: Prune set to 1536 MiB
2025-11-06 00:00:12.009 [INF] CHAN: Pre-alloacting for 251 MiB
2025-11-06 00:00:12.045 [INF] CHAN: Loading block index...
2025-11-06 00:00:16.667 [INF] CHAN: Chain state (height 922508, hash 00000000000000000000398224251b1ad28b08f4000ecdf148758c4ef7ee937f, totaltx 1267144083, work 75090201843685082224700644002)
2025-11-06 00:00:16.769 [INF] RPCS: RPC server listening on [::1]:8334
2025-11-06 00:00:16.769 [INF] RPCS: RPC server listening on 127.0.0.1:8334
2025-11-06 00:00:16.815 [INF] AMGR: Loaded 10798 addresses from file '/home/____________/.btcd/data/mainnet/peers.json'
2025-11-06 00:00:16.825 [INF] CMGR: 21 addresses found from DNS seed seed.bitcoin.wiz.biz
2025-11-06 00:00:16.852 [INF] CMGR: 2 addresses found from DNS seed seed.bitcoin.sipa.be
2025-11-06 00:00:16.854 [INF] CMGR: 2 addresses found from DNS seed seed.bitnodes.io
2025-11-06 00:00:16.855 [INF] CMGR: 36 addresses found from DNS seed seed.bitcoin.sprovoost.nl
2025-11-06 00:00:16.877 [INF] CMGR: 31 addresses found from DNS seed dnsseed.bluematt.me
2025-11-06 00:00:16.878 [INF] CMGR: 37 addresses found from DNS seed seed.btc.petertodd.net
2025-11-06 00:00:16.879 [INF] CMGR: 37 addresses found from DNS seed seed.bitcoin.jonasschnelli.ch
2025-11-06 00:00:16.879 [INF] CMGR: 36 addresses found from DNS seed dnsseed.bitcoin.dashjr.org
2025-11-06 00:00:16.980 [INF] SYNC: New valid peer [2607:5300:203:5b84::1]:8333 (outbound) (/Satoshi:29.0.0/)
2025-11-06 00:00:16.981 [INF] SYNC: Caught up to block 00000000000000000000398224251b1ad28b08f4000ecdf148758c4ef7ee937f(922508)
2025-11-06 00:00:17.081 [ERR] V2TR: Receive failed after reading 0 bytes (target 64): read tcp [2603:6011:7508:428e:cd52:a258:c26e:76a9]:40062->[2a01:4f8:262:4bc4::2]:8333: read: connection reset by peer
2025-11-06 00:00:17.081 [INF] PEER: Outbound v2 connection attempt to [2a01:4f8:262:4bc4::2]:8333 failed, willdowngrade to v1 (peer does not support v2)
2025-11-06 00:00:17.081 [INF] SRVR: Peer [2a01:4f8:262:4bc4::2]:8333 indicated v2->v1 downgrade. Marking for next attempt as v1.
2025-11-06 00:00:17.175 [ERR] V2TR: Receive failed after reading 0 bytes (target 64): EOF
2025-11-06 00:00:17.175 [INF] PEER: Outbound v2 connection attempt to 213.193.83.253:8333 failed, will downgrade to v1 (peer does not support v2)
2025-11-06 00:00:17.175 [INF] SRVR: Peer 213.193.83.253:8333 indicated v2->v1 downgrade. Marking for next attempt as v1.
2025-11-06 00:00:22.211 [INF] SRVR: Forcing V1 connection to [2a01:4f8:262:4bc4::2]:8333 as requested by P2P downgrader.
2025-11-06 00:00:22.346 [INF] SYNC: New valid peer [2a01:4f8:262:4bc4::2]:8333 (outbound) (/btcwire:0.5.0/btcd:0.24.2/)
2025-11-06 00:00:22.346 [INF] SYNC: Caught up to block 00000000000000000000398224251b1ad28b08f4000ecdf148758c4ef7ee937f(922508)
2025-11-06 00:00:22.346 [INF] SRVR: Forcing V1 connection to 213.193.83.253:8333 as requested by P2P downgrader.
2025-11-06 00:00:22.519 [INF] SYNC: New valid peer 213.193.83.253:8333 (outbound) (/btcwire:0.5.0/btcd:0.24.2/)
2025-11-06 00:00:22.519 [INF] SYNC: Caught up to block 00000000000000000000398224251b1ad28b08f4000ecdf148758c4ef7ee937f(922508)
Steps to reproduce
- configure a bunch of
addpeer=with nodes from bitnodes.io - start btcd
- run
btcctl getinfo -
connectionswill be3
Expected behaviour
I expected behaviour like bitcoind, where all the configured nodes were connected to and more.
Looking at the logs, it looks like the v2 -> v1 downgrade may be failing. But then I do see the new connections established again.
How many nodes are you adding via addnode?
So addnode= isn't actually a config option. Did you mean addpeer? https://github.com/btcsuite/btcd/blob/9ff0780da683ec1fa88ce9b9f2f4fd39d5592221/sample-btcd.conf#L91-L97
So
addnode=isn't actually a config option. Did you meanaddpeer?
yeah, addpeer, my bad x3
How many nodes are you adding via
addnode?
6, all picked off of bitnodes. only 3 are being connected to, and if i manually connect theres no issues.
Thanks for that information. If I look at the logs I see two peers we try to connect to, we go from v2 -> v1 and then we do the reconnection dance and they are connected again as new peers.
Do you have more logs where some of the some of the peers that you're trying to connect to via add peer don't actually connect after a period of time?
no, after the initial 2-3 connections the logs are silent. with debuglevel=PEER=debug there are no more outbound attempts seen.
aha, triggered it again! it seems if an ip is unreachable it permanently takes a peer slot? heres some addpeer=s with non-node ips, this resulted in only 2 outbound connections for me.
addpeer=178.126.109.109
addpeer=174.136.109.109
addpeer=174.126.109.109
addpeer=114.126.149.109
addpeer=171.126.139.109
addpeer=175.126.109.109
so, i guess my expectations are btcd will log an error for an unreachable peer, and that configured addpeer=s don't take slots if theres no active connection.