3

I have Geth running locally, and for whatever reason the JSON-RPC api is not working. Web3.js is working fine.

I've tried to start the console several ways:

geth --rpc --rpcapi "eth,net,admin,web3" --verbosity 0 --unlock 0 console

I've also included the port and other combinations, such as starting RPC from within the console using admin.startRPC(addr,host).

Each time I make an RPC call, for example: curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'

I get a variation of the following output:

(anonymous): Line 1:9 Unexpected identifier (and 1 more errors)

I've also tried RPC calls omitting -X POST or specifying rpcaddr:rpchost at the end.

I don't have any other connections, or other geth-attached windows.

1

To make an RPC call and get response, you need to initialize the target node with an --rpcaddr (IP Address) and an --rpcport. The default rpc port for geth is 8545. You can also start this process from the interactive JavaScript console using admin.startRPC(addr, port).

And while making an RPC call:

curl -X POST -d '{"method":"net_version","id":1}' rpcaddr:rpcport 

Replace the rpcaddr with your IP address and rpcport with 8545 if you haven't modified it.

I have simulated the same commands and I got the result. Geth node is running on one terminal and I made an RPC call from another terminal. Check out this screenshot: enter image description here

  • I omitted the rpcaddr:rpcport in my question but I have tried variations specifying `localhost:8545' at the end. I'll try specifying my ip address at the beginning. – Physes Jul 1 '16 at 13:20
  • Yep, just to confirm I tried restarting with those instructions and curl still produces the same output. – Physes Jul 1 '16 at 13:24
  • Assuming you're making an RPC request from a different workstation, you need to mention the IP address of the target computer, not localhost – galahad Jul 1 '16 at 13:26
  • The RPC command examples use localhost. I also tried it with my ip address, and nope. Syntax error? Does it have to be a string? – Physes Jul 1 '16 at 13:29
  • Btw, I've also tried the approach of starting from within geth: admin.startRPC(addr,port) and that also didn't work. The output was: listen tcp xxx.xxx.xxx.xx:8545: bind: cannot assign requested address. – Physes Jul 1 '16 at 13:32

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.