2

I am very new to blockchain. I try to go through the following example but I can not make the second node.

how-to-build-a-private-ethereum-blockchain

What I have done

I have two directories for each node in the go-ethereum directory(node1, node2).

I have two directories for the geth and keystore directory (.ethereum1, .ethereum2).

I made new account in each node directory.

I can make the first node and it works fine.

/home/user/Etherum/go-ethereum/build/bin/geth  --mine  --nodiscover  --maxpeers 1  --networkid 13  --port 30304 --datadir ~/.ethereum1 --rpc --rpccorsdomain "*"

However when I start the second one

/home/user/Etherum/go-ethereum/build/bin/geth  --mine  --nodiscover  --maxpeers 1  --networkid 13  --port 30305 --datadir ~/.ethereum2 --rpc --rpccorsdomain "*"

I set different port as it was the problem previously.

I have the following error

Fatal: Error starting protocol stack: listen tcp 127.0.0.1:8545: bind: address already in use

If what I am doing totally wrong then please explain me what to do.

Thank you

2 Answers2

3

Since v1.10.21 authrpc is enabled by default. If you want to run more than one node on localhost, you have to specify different port for every node using the --authrpc.port command line option.

persec10000
  • 131
  • 3
3

The RPC service has a default port, 8545. The first time you run Geth it's listening on that port, so the second time it finds that the port is already in use.

Try specifying a different port the second time, eg --rpcport 8546. Alternatively just run the second without RPC, you probably don't need it.

Edmund Edgar
  • 16,897
  • 1
  • 29
  • 58
  • Thank you I have to use the --rpcport 8546 for node1 and --rpcport 8547 for node2. When I have removed the --rpc then I was not able to make JSON-RPC call. – László Péter Varga Aug 27 '17 at 20:38
  • One more question if you do not mind @Edmund Edgar. How I can check that they are peering using the JSON-RPC method call? – László Péter Varga Aug 27 '17 at 20:41
  • Right, if you want to talk to all the nodes on RPC then you'll need the RPC service running on them. Often it's enough to have one node running RPC and send transactions through that one, but that'll depend on what you're doing. – Edmund Edgar Aug 27 '17 at 20:42
  • You should be able to hit the peercount call with curl: https://github.com/ethereum/wiki/wiki/JSON-RPC#net_peercount Alternatively attach to one of them with geth attach http://localhost:8545 and do admin.peers - see https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network – Edmund Edgar Aug 27 '17 at 20:45
  • I am just doing the example. I have to understand them first before I will do any special – László Péter Varga Aug 27 '17 at 20:48