Unable to add ethereum peer. Peer list is empty
Asked Answered
P

4

10

I am trying to setup a private ethereum network. I started two nodes in the same machine (Windows 7) in two different ports.

I am unable to add one node as the peer of the other node. What I have done so far is this.

Start two nodes with same network id, different data dirs, and different ports.

Find the node address of one node.

> admin.nodeInfo.enode
"enode://5d272e8bee6d29dfff6313999a4a2c3d8109ae6f3eb103480f4536c0542549b9fa12a8d8ae5ebee9c4db55cab553693b04eedbc9b29f35bbc0af1956231b42b4@0.0.0.0:30303"

Add the node to the other peer.

> admin.addPeer("enode://5d272e8bee6d29dfff6313999a4a2c3d8109ae6f3eb103480f4536c0542549b9fa12a8d8ae5ebee9c4db55cab553693b04eedbc9b29f35bbc0af1956231b42b4@192.168.1.5:30303")

true

But, if I check peer information of the second peer, it shows that it doesn't have any peers.

> admin.peers

[]

Also, I tried to add the first peer as a static peer for the second node by adding node address to data/static-nodes.json, but still admin.peers returns an empty list.

Does anyone know how to fix this?

Punctuation answered 30/10, 2016 at 12:20 Comment(1)
Best asked on ethereum.stackexchange.comUndaunted
A
3

There are many reasons which could prevent the nodes to get sync-ed.

System Clocks not Sync

One of the most common but difficult-to-find reasons is that the system clocks of the devices do not sync. The nodes do not sync even if the clocks are differ by just 12 seconds.

From https://github.com/ethereum/wiki/wiki/Mining :

The difficulty dynamically adjusts so that on average one block is produced by the entire network every 12 seconds (ie., 12 s block time). This heartbeat basically punctuates the synchronisation of system state and guarantees that maintaining a fork (to allow double spend) or rewriting history is impossible unless the attacker possesses more than half of the network mining power (so called 51% attack).

The problem could be solved by using the same NTP server (preferably geographically close to the network) on all devices.

Network IDs not Matched

By using the --networkid 12345 option on the command line, the network ID of the network is set to 12345. Please make sure that the settings are the same among all nodes, and that the value is a random positive unsigned 32-bit number (ie. 1 ~ 2147483647). Do not use 12345, since there may be too many people using it.

Firewall not Properly Configured

Ethereum uses TCP and UDP ports 30303 by default to communicate with each other. Please make sure that both 30303/TCP and 30303/UDP are not blocked by the firewall on the device.

Arabeila answered 17/5, 2017 at 6:40 Comment(0)
W
0

Another option which is missing in the previous answer, here is genesis.json: it should be the same on all nodes.

Weismann answered 8/8, 2017 at 2:51 Comment(0)
F
0

There are a few issues that could be causing it as mentioned in the other answers. It could be that you are only configuring one port and not both. you need to set both the port and rpcport. Ipc path either needs to be enabled or disabled as well --ipcpath or --ipcdisable.

The problem is most likely in the way you initialized the nodes, which has been my experience.

On top of the above, make sure you use the same genesis block from both which should look like so

{
 "alloc": {},
 "coinbase"   : "0x0000000000000000000000000000000000000000",
 "difficulty" : "0x20000",
 "extraData"  : "",
 "gasLimit"   : "0x2fefd8",
 "nonce"      : "0x0000000000000042",
 "mixhash"    : 
 "0x0000000000000000000000000000000000000000000000000000000000000000",
 "parentHash" : 
 "0x0000000000000000000000000000000000000000000000000000000000000000",
 "timestamp"  : "0x00"

}

You may also want to specify your UDP port as shown below with discport, which is shown below, and use the --bootnodes argument. The directions for bootnodes are in both of the following resources I linked.

    >admin.addPeer("enode://90b7cbbaee94ab6e5bc7c5e8080bf8e2dfed5047b7c19ac61ee82511bef40faf9be2066258228ce7a71ab97b508dbef3c8f50fcf31dedfd43f2f0abd7f618db9@172.129.23.46:30303?discport=0")
true

These are two walk throughs you can compare for your initialization.

https://github.com/ethereum/go-ethereum/wiki/Setting-up-private-network-or-local-cluster https://ethereum.stackexchange.com/questions/13547/how-to-set-up-a-private-network-and-connect-peers-in-geth/15638

Frediafredie answered 11/8, 2017 at 20:28 Comment(0)
W
0
geth --datadir datadir2 **--networkid 123456** --rpc --rpcport "8549"  --rpccorsdomain "*"  --port 30304 --nodiscover --rpcapi="admin,db,eth,debug,miner,net,shh,txpool,personal,web3"

networkid in both the nodes should be same. Here it is 123456. Try with the same network id in another node then up the node.

Woodwind answered 14/10, 2019 at 12:0 Comment(1)
Welcome to stackoverflow please consider clarifying your answer. there are improvements you could make on the grammar to make it a better answer.Loralorain

© 2022 - 2024 — McMap. All rights reserved.