3
var web3 =  new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.getBalance(address) 

throws an error:

Invalid JSON RPC response: ""

while address is some existing valid address.

geth is running.

What could possibly cause that?

  • What is your geth command line? Is rpc interface enabled? It should be something like geth --rpc <other options>. – Ismael Nov 28 '17 at 20:57
  • @Ismael no just geth. Is that the problem? Are you sure? Because I do manage to create accounts via web3, but not to get their balances. This code does work: web3.eth.accounts.create(); – Alon Nov 28 '17 at 21:35
  • Did you try to launch geth with said command line option? – Ismael Nov 29 '17 at 4:52
  • @Ismael yes I did and I don't get this error anymore, thank you. You can write it as an answer and I will accept it. – Alon Dec 2 '17 at 19:37

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.