I'm very new Ethereum and trying to follow this tutorial:
But when I run:
web3.eth.accounts
I get an error:
Error: Invalid JSON RPC response: undefined
at Object.InvalidResponse (/Users/me/Ethereum/hello_world_voting/node_modules/web3/lib/web3/errors.js:38:16)
at HttpProvider.send (/Users/me/Ethereum/hello_world_voting/node_modules/web3/lib/web3/httpprovider.js:95:18)
at RequestManager.send (/Users/me/Ethereum/hello_world_voting/node_modules/web3/lib/web3/requestmanager.js:58:32)
at Eth.get [as accounts] (/Users/me/Ethereum/hello_world_voting/node_modules/web3/lib/web3/property.js:107:62)
at repl:1:9
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:433:10)
Everything up until this worked.
Looks like an associated question here, but I don't have enough background to understand and follow it.
Error: Invalid JSON RPC response: undefined from node web3.js app
Can anyone point me in the right direction?
Best Answer
I had the same issue, and just found the solution. This response happens when testrpc is not running, as stated by @Abhishek in the comments.
To solve it, the trick is to run testrpc in another terminal window:
Install web3 and testrpc packages:
npm install ethereumjs-testrpc web3@0.20.1
In the same terminal window, run testrpc:node_modules/.bin/testrpc
Open a NEW terminal window (with the first one still open and running), and run node :Finally, you can run:
> web3.eth.accounts
You will get the list of accounts.