[Ethereum] How to use geth attach and port numbers

go-ethereum

I am attempting to connect using two nodes on separate machines:

geth attach

I enter this in machine 2-

geth attach http://10.132.0.2:8501

and get this –

Fatal: Failed to start the JavaScript console: api modules: 
Post http://10.132.0.2:8501: dial tcp 10.132.0.2:8501: getsockopt: connection refused

I am not that clear on how the nodes connect either using UDP or TCP; or if http is used.

How can I debug this? Should we be using enode anyway?

The node is running on machine 1.

From machine 1 hosting the node


Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:8501          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8502          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 10.132.0.2:22           92.238.41.13:49637      ESTABLISHED
tcp        0    316 10.132.0.2:22           92.238.41.13:50681      ESTABLISHED
tcp        0      0 10.132.0.2:51968        169.254.169.254:80      ESTABLISHED
tcp        0      0 10.132.0.2:51944        169.254.169.254:80      CLOSE_WAIT 
tcp        0      0 10.132.0.2:22           92.238.41.13:50671      ESTABLISHED
tcp        0      0 10.132.0.2:22           92.238.41.13:50036      ESTABLISHED
tcp        0      0 10.132.0.2:51978        169.254.169.254:80      ESTABLISHED
tcp        0      0 127.0.0.1:54108         127.0.0.1:30311         ESTABLISHED
tcp        0      0 10.132.0.2:51962        169.254.169.254:80      ESTABLISHED
tcp        0      0 10.132.0.2:22           92.238.41.13:49959      ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::30311                :::*                    LISTEN     
tcp6       0      0 :::30312                :::*                    LISTEN     
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 127.0.0.1:30311         127.0.0.1:54108         ESTABLISHED
udp        0      0 0.0.0.0:68              0.0.0.0:*                          
udp        0      0 10.132.0.2:123          0.0.0.0:*                          
udp        0      0 127.0.0.1:123           0.0.0.0:*                          
udp        0      0 0.0.0.0:123             0.0.0.0:*                          
udp6       0      0 :::30310                :::*                               
udp6       0      0 :::30311                :::*                               
udp6       0      0 :::30312                :::*                               
udp6       0      0 fe80::4001:aff:fe84:123 :::*                               
udp6       0      0 ::1:123                 :::*                               
udp6       0      0 :::123                  :::*

from geth on machine 1 (running node)

admin.nodeInfo { enode: "enode://d889d565b3ddc37491d131aed1c23d0a7b30a185bb925f325c7830b2ae710bc127010487f39f32d889afd1284ea31aa893adddda2197f2763485926970620381@[::]:30312",
id:
"d889d565b3ddc37491d131aed1c23d0a7b30a185bb925f325c7830b2ae710bc127010487f39f32d889afd1284ea31aa893adddda2197f2763485926970620381",
ip: "::", listenAddr: "[::]:30312", name:
"Geth/v1.8.2-stable-b8b9f7f4/linux-amd64/go1.9.4", ports: {
discovery: 30312,
listener: 30312 }, protocols: {
eth: {
config: {
byzantiumBlock: 4,
chainId: 1515,
clique: {…},
eip150Block: 2,
eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
eip155Block: 3,
eip158Block: 3,
homesteadBlock: 1
},
difficulty: 27923,
genesis: "0x702d8ca9647d171a6596a775888f71c7c0f3ddb011fbffcb921be685b2ef33b7",
head: "0xa9e2d5d7e55653b9a0b47ddfa0650105a9d0e5487b6cff207d191d33cdefa830",
network: 1515

Here is the connection
string for node1 –

nohup geth –datadir node1/ –syncmode 'full' –port 30311 –rpc
–rpcaddr 'loca lhost' –rpcport 8501 –rpcapi 'personal,db,eth,net,web3,txpool,miner' –bootnod es
'enode://601ade737b81f16abdd0ce9983b63eb12050c4ef89c46b8fdbf3e3e6c951cc02dffe
36f87200033107cf8b007355e780fba16b67d1d46603b1321f07314ea46b@127.0.0.1:30310'
— networkid 1515 –gasprice '1' -unlock 'fcad53c780a4f6c66b3daca331fe72fc6559c367' –password
node1/pwdnode1.txt –mine &

Best Answer

Your RPC listening address is 127.0.0.1, which can only be connected from the same host.

If you need to connect from across networks, try --rpcaddr 10.132.0.2

Related Topic