I have built go-ethereum from source and I'm running on Ubuntu in a Docker container. I can run geth commands from the command line just fine, but I'm having trouble attaching to it or curling RPCalls to it.

For example:

nohup geth --verbosity 0 --rpc import /home/myvbo/cloudwallets/serverbinaries/blockchainTo1463224 &
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' localhost:8545
geth attach http://localhost:8545

The error message for the curl is curl: (7) Failed to connect to localhost port 8545: Connection refused

The error message for the attach is Fatal: Unable to attach to geth node - Invalid endpoint

What am I missing? Have I not completely configured geth for RPC?

  • Can you check if geth is running inside docker? It may failed to start. As a test you may try to attach using ipc.If geth is running perhaps some other program is using port 8545, use netstat -nlp to find the open ports.
    – Ismael
    Commented Jun 7, 2016 at 6:15
  • I am starting with the simplest case, running the docker container to start a shell, then running geth and curl from the command line, inside the container.
    – B.Thecode
    Commented Jun 7, 2016 at 14:03

2 Answers 2


When you start Geth it may take some seconds for it to finish booting. Only after finishing the startup will the HTTP/IPC/WS endpoints be opened, so you'll need to wait for that to happen before you can send requests to it.

Edit: Do note, Geth has a lot of administrative subcommands (e.g. account, import, upgradedb, etc) which only execute some predefined functionality and then terminate. They do not start a node, so there's nothing to connect to.

  • I thought that this might be the case as well, but I get the same result if I wait a minute, several minutes, or ten minutes. Your point does give me an idea, however; as I am launching geth with parameters to import a saved blockchain, is it possible that the endpoints don't get opened until the import finishes?
    – B.Thecode
    Commented Jun 7, 2016 at 14:06
  • Ahh, now I see. Running import is a separate command that just loads a blockchain and then exists. It doesn't start geth or anything related to it. Commented Jun 7, 2016 at 14:51
  • I just tried mining after the import completes, and then curling the same POST. Geth is still mining as I write this, and still refusing the connection.
    – B.Thecode
    Commented Jun 7, 2016 at 15:19
  • I tried the attach without an endpoint (as in 'geth attach') and I get a different error message: 'Fatal: Unable to attach to geth node - dial unix /root/.ethereum/geth.ipc: connect: no such file or directory' This persists even after applying chown and chmod to the parent of geth.ipc so something larger appears to be a problem.
    – B.Thecode
    Commented Jun 7, 2016 at 15:36

What I needed to was

  1. Wait until the import had completed
  2. Wait a few minutes after I ran geth with --rpc to download the rest of the blockchain.

That's it. I just needed to wait twice. Thank you Péter!

  • 1
    You can mark this answer as accepted by clicking the tick on the left if this is what solved your problem.
    – q9f
    Commented Jun 16, 2016 at 10:03

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.