1

I am trying to add two peers in ethereum privatenet but not adding its shows peer count is 0. I run the below commands

Node1:

geth --identity "Privatenet1" --datadir=./Privatenet1 --networkid 1995 --nodiscover --maxpeers=2 --mine --syncmode fast --port 30303 --rpc --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --nat "any"

Node2:

geth --identity "Privatenet2" --datadir=./Privatenet2 --networkid 1995 --nodiscover --maxpeers 2 --mine --syncmode fast --port 30305 --rpc --rpcport 8540 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --nat "any"

my genesis.json file for both nodes is given bellow:

{
   "config": {
      "chainId": 1995,
      "homesteadBlock": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
   },
   "difficulty": "400",
   "gasLimit": "2000000",
   "alloc": {
      "a620c4ffe82b2d2a4f3a9efc9d8c88f960696464": { 
          "balance": "100000000000000000000000" 
      },
      "db93c17c1b206ad4925e72896888012ea56a6005": { 
          "balance": "120000000000000000000000" 
      }
   }
}

then I tried to add node2 peer in node1 as below:

admin.addPeer("enode://cb2b35bc613fb9e700a5884c0e1bcb4e69e908e1a4509999ba51646cc443743b21b3d5e5c4b9353351a20a4e27321ad310e0fdcc60f26b4e975f5f133707615c@127.0.0.1:30305?discport=0")

enode is validated and showing true but peer count is still 0 and admin.peers is null. I researched on it and I allowed all ports using sudo ufw allow portnumber and telnet 127.0.0.1 30303 throwing Error like Connection closed by foreign host. is it firewall blocks my connection? can anyone please tell me the solution to resolve this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.