Can't find peers on local private network

by Zephyrus   Last Updated June 29, 2020 20:28 PM

I'm running two geth nodes on the same machine. It is a private network. They were both initialized with the same genesis block, and they both have the same network id.

When I try to add them as peers, neither one works.

Here is how I start Client 1:

$ geth --datadir private-chain --networkid 1994 --port 30303 --nodiscover --nat any --mine --miner.threads 4 --http --http.addr 127.0.0.1 --http.port 8545 --http.api eth,net,web3,personal console 2> private-chain/private-chain.log

And here is what I see in the console when I try to add Client 2 as its peer:

> admin.nodeInfo.enode
"enode://dbc09e2a5dab8d04a5d29f120ec77c110a0d99c2f87c460b588fb26d23f4d4686[email protected]127.0.0.1:30303?discport=0"
> admin.nodeInfo.ip
"127.0.0.1"
> admin.nodeInfo.listenAddr
"[::]:30303"
> net.listening
true
> admin.addPeer('enode://062245b30dfed5dcca2661fd2769debe998a78c2a6cdf0f9ffb3fac26317c8335[email protected]127.0.0.1:30304?discport=0')
true
> admin.peers
[]

Here is how I start Client 2 (the main differences from above are that the second client has a different datadir and uses different ports):

geth --datadir private-chain-peer --networkid 1994 --port 30304 --nodiscover --nat any --mine --miner.threads 4 --http --http.addr 127.0.0.1 --http.port 8546 --http.api eth,net,web3,personal console 2> private-chain-peer/private-chain.log

And here is what I see in the console when I try to add Client 1 as its peer:

> admin.nodeInfo.enode
"enode://062245b30dfed5dcca2661fd2769debe998a78c2a6cdf0f9ffb3fac26317c8335[email protected]127.0.0.1:30304?discport=0"
> admin.nodeInfo.ip
"127.0.0.1"
> admin.nodeInfo.listenAddr
"[::]:30304"
> net.listening
true
> admin.addPeer('enode://dbc09e2a5dab8d04a5d29f120ec77c110a0d99c2f87c460b588fb26d23f4d4686[email protected]127.0.0.1:30303?discport=0')
true
> admin.peers
[]

It behaves the same way if I remove the "?discport=0" from the enode strings. Sometimes the peer will show up for a split second then disappear, but even that is rare. My goal is to get them both mining and syncing each other on the same network.

What am I missing?



Related Questions






Where to place static-nodes.json for geth

Updated July 17, 2018 21:28 PM