My geth node is located in a remote machine (running on Ubuntu). The safe connection is provided by SSH protocol. Now I am trying use JSON RPC API.
So, the command geth --rpc returns response like this: HTTP endpoint opened: http://localhost:8545 Listening on [::]:30303 ...
Next I send the first JSON-RPC request. For example, curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67} http://localhost:8545'
However my client get the same command from server, without any response.
Why can this behaviour occur?

  • Judging from your answer, your question should be "How to keep geth alive in remote server?"
    – niksmac
    Nov 28, 2016 at 2:40

2 Answers 2


Worked for me, just add a single quote after the closing curly brace and the content-type header

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://localhost:8545


  • Thank for your answer, Herman, but it still returns my inputed command, without any response. Furthermore history command shows me that server did not recieve curl request after geth --rpc. Do you know can this behavior pertain to linux-machine (for example, when terminal is disable) or geth? Nov 26, 2016 at 18:07

The thing was a necessity of understanding of Linux shell's work.

When we input some command like $ geth --rpc the shell looks up needed program (geth) and creates a child process for it. Then it wait untill geth terminates its working.
Therefore if now we trying to send some command to shell or even geth they do not return needed response since shell is waiting for geth and geth is listening port to work with rpc protocol.

There is the solution. We just run geth as background process:

$ geth --rpc &

(with & symbol in the end)

Well, it works, shell in not blocking, geth is listening port 8545, however if we send some command to shell after this (for example, for curl) it automatically stops geth process. This behavior is set by default and occurs because the standard input of background process is associated with controlling terminal (window) still, it gets SIGTTIN signal when user inputs a command to there, which by default causes the program to be stopped.

So, we need to disable getting input stream from window:

geth --rpc </dev/null >&1 &

where < is input stream (it is associated with /dev/null, i.e. empty file which discards all written data) and > is output stream (it is associated with "&1" i.e. standard output stream, or window).

That's all. Now we can input some command to curl which then sends needed request for geth JSON RPC and returns response:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://localhost:8545

edit: according another part of my question, it confused me that inputted command is sending back. Actually it is normal fact, shell displays all strings which being treated. To disable it:

stty -echo

Your Answer

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

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