Go-ethereum: Ethereum client-go RPC response 403 “invalid host specified”

Created on 18 Apr 2018  Â·  5Comments  Â·  Source: ethereum/go-ethereum

System information

Geth version: latest docker version
OS & Version: Linux ( version from docker image)

I'm running ethereum/client-go docker image with the following flags:

docker run -p 8545:8545 ethereum/client-go --rpcapi personal,db,eth,net,web3 --rpc --rpcaddr 0.0.0.0 --rpccorsdomain * --rinkeby

This image is running on machine A and I can query the RPC within it. But when I try to query it from machine B I receive response 403 “invalid host specified”:

Request:
curl -X POST http://<machine_A_address>:8545 -H "Content-Type: application/json" --data '{"jsonrpc":"2Ă·.0","method":"eth_coinbase","params":[],"id":64}' --verbose

Response:

< HTTP/1.1 403 Forbidden
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Wed, 18 Apr 2018 14:58:44 GMT
< Content-Length: 23
< 
invalid host specified
* Connection #0 to host ... left intact

How can I query the ethereum client hosted on machine A from machine B ? Where I can find the ethereum client logs so I can debug it ?

Most helpful comment

Adding --rpcvhosts=* this flag solved the issue

All 5 comments

Adding --rpcvhosts=* this flag solved the issue

closing as it is solved

Hello,
I am trying to host geth via ubuntu18 LTS using below command
geth --datadir ~/eth-dev/ --networkid 45634 --verbosity 4 --ipcdisable --rpc --port 30301 --rpcport 8545 --rpcaddr ec2-18-233-100-194.compute-1.amazonaws.com console 2>> ~/eth-dev/eth.log

In my eth.log i see that genesis block missmatch and connected to port 8545:

DEBUG[04-12|23:55:40.606] HTTP registered namespace=net
INFO [04-12|23:55:40.610] Started P2P networking self=enode://f35d5d8373e2337643b317030c5058eca6860328a1c7999be755426724b5256bdf29513ba919106974927cda3bdffed36f5c13caecc00c82c2504b545c225d7d@127.0.0.1:30301
INFO [04-12|23:55:40.627] HTTP _endpoint opened url=http://ec2-18-233-100-194.compute-1.amazonaws.com:8545 cors= vhosts=localhost_
DEBUG[04-12|23:55:41.021] Adding p2p peer name=Geth/v1.8.13-stable-... addr=47.254.74.185:30303 peers=1
DEBUG[04-12|23:55:41.021] Ethereum peer connected id=4f9c5ff2db74607b conn=dyndial name=Geth/v1.8.13-stable-225171a4/linux-amd64/go1.10
DEBUG[04-12|23:55:41.093] Ethereum handshake failed id=4f9c5ff2db74607b conn=dyndial err=EOF
DEBUG[04-12|23:55:41.093] Removing p2p peer id=4f9c5ff2db74607b conn=dyndial duration=72.158ms peers=0 req=true err="client quitting"
DEBUG[04-12|23:55:42.699] Couldn't add port mapping proto=tcp extport=30301 intport=30301 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DEBUG[04-12|23:55:42.699] Couldn't add port mapping proto=udp extport=30301 intport=30301 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DEBUG[04-12|23:55:44.816] Revalidated node b=16 id=930cf49cd4de09a6 checks=1
DEBUG[04-12|23:55:53.293] Revalidated node b=9 id=4c124ff2ce9afd82 checks=1
DEBUG[04-12|23:55:55.888] Adding p2p peer name=REOSC/v2.2.2-securit... addr=149.28.120.201:30303 peers=1
DEBUG[04-12|23:55:55.888] Ethereum peer connected id=4d068e1c66c82a21 conn=dyndial name=REOSC/v2.2.2-security-a32dc51-20190311/x86_64-linux-gnu/rustc1.30.0
_DEBUG[04-12|23:55:55.911] Ethereum handshake failed id=4d068e1c66c82a21 conn=dyndial err="Genesis block mismatch - af95c2c734e3d58c (!= 5e1fc79cb4ffa473)"
DEBUG[04-12|23:55:55.912] Removing p2p peer id=4d068e1c66c82a21 conn=dyndial duration=23.990ms peers=0 req=false err="Genesis block mismatch - af95c2c734e3d58c (!= 5e1fc79cb4ffa473)
_"

I tried to add --rpcvhost=* even them when i try to access the rpc from browser I see the error :invalid host specified 403 forbidden the ports 30301 and 8545 are allowed via AWS security group as well.

Below is my genesis block:
{
"config": {
"chainId": 45634,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": {}
}

Please let me know if I am missing something? I am expecting to see the JSON RPC data while hitting the URL: http://ec2-18-233-100-194.compute-1.amazonaws.com:8545 instead.

@SaiTejaMakani several things

  • it's not surprising that peers have a different genesis, since you use a custom one
  • you didn't set vhosts for geth, not in the log output above, at least
  • I don't think geth json-rpc honors browser GET. You need a proper json-rpc post to get anything back

Adding --rpcvhosts=* this flag solved the issue

Served eth_getBalance conn=172.18.0.2:34628 reqid=1 t=3.013703915s err="getDeleteStateObject

THX

Was this page helpful?
0 / 5 - 0 ratings