8

I'm getting Error: Invalid JSON RPC response: undefined from my node.js application when it tries to execute a function. My steps:

  1. ethereum wallet 0.5.1 to deploy a contract to the testnet.

  2. start the geth client version 1.3.3:

    $ geth --rpc --rpcaddr "0.0.0.0" --rpcapi "eth,web3" --rpcport 8546 --networkid 5678 attach
    

(I can run web3.eth.accounts from within the geth console and it returns my locally created accounts)

  1. used npm to install web3 version 0.15.3

  2. from within the node shell:

    > var Web3 = require('web3')
    > web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8546"))
    > web3.version.api
    '0.15.3'
    > web3.eth.accounts
    Error: Invalid JSON RPC response: undefined
    at Object.module.exports.InvalidResponse (/Users/jbowkett/node_modules/web3/lib/web3/errors.js:35:16)
    at HttpProvider.send (/Users/jbowkett/node_modules/web3/lib/web3/httpprovider.js:87:22)
    at RequestManager.send (/Users/jbowkett/node_modules/web3/lib/web3/requestmanager.js:58:32)
    at Eth.get [as accounts] (/Users/jbowkett/node_modules/web3/lib/web3/property.js:107:62)
    at repl:1:9
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:82:20)
    

Also : $ telnet localhost 8546 yields no connection

  • eth.accounts is undefined; try start geth with --etherbase flag along with your address. – niksmac Mar 15 '16 at 13:54
  • @NikhilM how come it works in the geth console?....I should have clarified, this seems to be the response I get for any methods I call on the web3 instance – James B Mar 15 '16 at 13:59
  • So you have working accounts in geth? any CORS errors on the console? – niksmac Mar 15 '16 at 14:18
  • @nikhilm Yes I believe so - I see no errors in geth for the same calls as I am trying to make over web3 – James B Mar 15 '16 at 14:54
  • This issue has been solved here: ethereum.stackexchange.com/questions/23719/… – marcvander Aug 28 '17 at 8:43
10

from the geth console:

admin.startRPC("127.0.0.1", 8545, "*", "web3,db,net,eth")

then I was able to reconnect in node, and list the accounts. (unsurprisingly, telnet responded on this port too after starting RPC from within geth)

Taken from here:

web3 methods not implemented

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.