I'm getting following error (Base path of file is replaced with <>) -
Error: Invalid JSON RPC response: "invalid host specified\n"
at Object.InvalidResponse (<>/node_modules/web3/lib/web3/errors.js:38:16)
at HttpProvider.send (<>/node_modules/web3/lib/web3/httpprovider.js:91:22)
at RequestManager.send (<>/node_modules/web3/lib/web3/requestmanager.js:58:32)
at Eth.get [as gasPrice] (<>/node_modules/web3/lib/web3/property.js:107:62)
at Object.getGasPrice (<>/helpers/ether.helper.js:43:31)
When making any RPC call, if my Host in provider is a domain.
const etherAddress = "http://ethernode:8545";
const provider = new Web3.providers.HttpProvider(etherAddress);
In my /etc/hosts file
...
192.168.23.33 ethernode # Random IP
...
But, If I'm changing the ether address to "http://192.168.23.33:8545", all the methods are working as expected.
Is there any configuration that I'm missing?
Here is how my geth is running -
./geth --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --datadir /crypto/geth
Hi, I have just noticed the same behavior for a configuration that was working several months ago.
My config was not far from yours
I am now using last version of ethereum geth, and it seems there is another parameter to provide :
--rpcvhosts value Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
I haven't made the test yet but I hope this will correct your issue (and also mine :-) )
Happy easter !
@stephgou is correct, you need to configure the whitelist the domain in the rpc. I wouldn't recommend '*' for security reasons..
I just ran across this thread which seems incoherent. I encountered the same problem as the OP, i.e., the RPC interface returns "invalid host specified\n"
The problem is overcome by omitting/bypassing DNS reference and directly specifying the server IP address in the client request. The failure is exhibited regardless of the geth option: --rpcvhosts '*', which I interpret as a filter for the client ID, not the server ID. I am unable (as yet) to successfully issue requests that identify a server by DNS name.
I am using web3py.
@ElectricBill run into this too. did you find any solution for this?
Most helpful comment
Hi, I have just noticed the same behavior for a configuration that was working several months ago.
My config was not far from yours
I am now using last version of ethereum geth, and it seems there is another parameter to provide :
--rpcvhosts value Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
I haven't made the test yet but I hope this will correct your issue (and also mine :-) )
Happy easter !