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?

4
  • What is your geth command line? Is rpc interface enabled? It should be something like geth --rpc <other options>.
    – Ismael
    Commented Nov 28, 2017 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
    Commented Nov 28, 2017 at 21:35
  • Did you try to launch geth with said command line option?
    – Ismael
    Commented Nov 29, 2017 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
    Commented Dec 2, 2017 at 19:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.