I want to connect to my running geth --testnet.

If I run geth --testnet attach, just like geth attach I get :

Fatal: Unable to attach to remote geth: dial unix /user/.ethereum/geth.ipc: connect: no such file or directory

Which is normal, because geth.ipc is not in .ethereum but in .ethereum/testnet.

Is there a way to use an option to make geth look for geth.ipc in the right folder when I'm using the testnet ?

It can be a little heavy to write full ipc path every time (Right now I use geth attach ipc:/path/to/ipc and often start it by hand).

Edit: I found an open issue on github that suggests there is no way to use options with attach yet. I'm now only asking for ways to do it faster than writing full path.

  • Try: geth attach
    – alper
    Mar 7, 2021 at 14:27

7 Answers 7


I have an alias on my computer (Linux) that lets me do this quickly. I just put

alias gat='geth attach ipc://${HOME}/.ethereum/testnet/geth.ipc'

in my .bashrc.

You could also, alternatively, alias geth itself, i.e.

alias geth='geth --ipcpath ipc://${HOME}/.ethereum/geth.ipc'

so that the ipc file is placed in the default location regardless of which network you are using. You can always call \geth --args if you want to use the raw command without the alias.

On windows, I believe you can use

doskey gat=geth attach ipc://%APPDATA%\Ethereum\geth.ipc or something of the sort

  • seems like -ipcpath flag does not exist with the latest geth
    – alper
    Mar 7, 2021 at 14:24

You can specify where to create ipc file and where to find it while attaching:

$ geth --testnet --ipcpath /tmp/geth
$ geth attach /tmp/geth

Another option is to attach via HTTP-RPC:

$ geth --testnet --rpc
$ geth attach http://:8545

Please note, only eth,net,web3 API modules are provided via HTTP-RPC by default. You need to specify additional modules explicitly if you require them:

$ geth --testnet -rpc --rpcapi "admin,eth,miner,net,personal,web3"
  • 1
    +1 for geth attach
    – alper
    Mar 7, 2021 at 14:22

You can specify the ipc path with the --ipcpath "/path/to/my/geth.ipc" option

--ipcpath "geth.ipc"     Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  • I'm looking for a quicker method. My path is pretty long and not default, and I often have to type it by hand. I edited my question for clarity. Jan 9, 2017 at 16:57
  • 1
    use linux variables to set your path exp : export IPC_PATH="/var/......" next time use $MY_PATH
    – Badr Bellaj
    Jan 9, 2017 at 17:04
  • 1
    seems like -ipcpath flag does not exist with the latest geth
    – alper
    Mar 7, 2021 at 14:25


if you can learn from log

INFO [03-19|15:31:25] IPC endpoint opened                      


you can geth attach ipc:/Users/XXXX/dataEth2/geth.ipc


This is a bit of a nuclear option, but you can create a symlink called geth.ipc in .ethereum which points to the actual, testnet geth.ipc. I can confirm this works, as I've done this myself.

  • That's interesting. What happens if geth --testnet is closed and someone opens geth ? Will it replace the symlink ? Or if geth is closed so geth.ipc doesn't exist, but the symlink does ? Do we get a standerd error ? Jan 10, 2017 at 15:40
  • I'm actually not sure. I use it because my datadir is on another partition (though I realize I probably could have just symlinked the whole directory). The symlink will definitely still exist if there's nothing it points at. Jan 10, 2017 at 16:08
  • I myself have symlinked my whole .ethereum folder to another disk, it works great ! Jan 10, 2017 at 16:18

You can add --rpc in geth command line

and then you can attach with geth attach http://localhost:8454.

  • Try to understand the question and then answer. Try to be more explanatory, and avoid spell mistakes.
    – Rajesh
    Mar 19, 2018 at 9:13
  • Fatal: Failed to start the JavaScript console: api modules: Post "localhost:8454": dial tcp connect: connection refused
    – alper
    Mar 7, 2021 at 14:25

Since you will normally only run the testnet or the main net - why not fix your ipc always in the same place in the main call to geth? Then geth attach (and MIST) knows where to look for it....

  • 2
    How do I do that ? geth.ipc is created automatically when I run geth and deleted when I close it. Jan 9, 2017 at 17:16
  • you can set the ipcpath with the --ipcpath flag so create a script that runs the testnet but uses the standard path. Jan 15, 2017 at 20:31

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.