Go-ethereum: Unable to attach to the local running geth node

Created on 28 May 2017  路  17Comments  路  Source: ethereum/go-ethereum

Hi, I'm trying to run a geth node and attach to but can't do it.

System information

Geth version:

Version: 1.6.1-stable
Git Commit: 021c3c281629baf2eae967dc2f0a7532ddfdc1fb
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.8.1
Operating System: linux
GOPATH=
GOROOT=/usr/local/go

OS & Version:

Centos7 Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Expected behaviour

I'm able to connect to the running node with geth attach

Actual behaviour

[root@localhost ~]# geth -rinkeby attach
Fatal: Unable to attach to remote geth: dial unix /root/.ethereum/geth.ipc: connect: no such file or directory

Steps to reproduce the behaviour

  1. Run geth in rinkeby network.
[root@localhost ~]# geth -rinkeby
WARN [05-28|15:21:20] No etherbase set and no accounts found as default
INFO [05-28|15:21:20] Starting peer-to-peer node               instance=Geth/v1.6.1-stable-021c3c28/linux-amd64/go1.8.1
INFO [05-28|15:21:20] Allocated cache and file handles         database=/root/.ethereum/rinkeby/geth/chaindata cache=128 handles=1024
INFO [05-28|15:21:21] Initialised chain configuration          config="{ChainID: 4 Homestead: 1 DAO: <nil> DAOSupport: true EIP150: 2 EIP155: 3 EIP158: 3 Engine: clique}"
INFO [05-28|15:21:21] Initialising Ethereum protocol           versions="[63 62]" network=4
INFO [05-28|15:21:21] Loaded most recent local header          number=264232 hash=98e342鈥7af23 td=506912
INFO [05-28|15:21:21] Loaded most recent local full block      number=264232 hash=98e342鈥7af23 td=506912
INFO [05-28|15:21:21] Loaded most recent local fast block      number=264232 hash=98e342鈥7af23 td=506912
WARN [05-28|15:21:21] Blockchain not empty, fast sync disabled
INFO [05-28|15:21:21] Starting P2P networking
INFO [05-28|15:21:23] RLPx listener up                         self=enode://89c0afe94cffa6c8a7765706de732e6954df5c320b952eb00622679232d9c61b71d4b2aff254dc02ab4e9860aa57fc1f3257e9905947148d01e96a03831401f5@[::]:30303
INFO [05-28|15:21:23] IPC endpoint opened: /root/.ethereum/rinkeby/geth.ipc
INFO [05-28|15:21:33] Block synchronisation started
  1. Open another terminal and try to attach to it and see the error message:
[root@localhost ~]# geth -rinkeby attach
Fatal: Unable to attach to remote geth: dial unix /root/.ethereum/geth.ipc: connect: no such file or directory

Summary

This behaviour seems incorrect, let me know if I do something wrong. If I connect to a network and then specify the same network in the attach function, I expected geth to successfully attach to the running node.

I've also tried to specify datadir:

[root@localhost ~]# geth -rinkeby --datadir="/root/.ethereum/rinkeby" attach
Fatal: Unable to attach to remote geth: dial unix /root/.ethereum/geth.ipc: connect: no such file or directory

And if you read the documentation on attach you'll see this:

[root@localhost ~]# geth attach --help
attach [command options] [arguments...]

The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the 脨app JavaScript API.
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.
This command allows to open a console on a running geth node.

OPTIONS:
  --jspath loadScript          JavaScript root path for loadScript (default: ".")
  --exec value                 Execute JavaScript statement
  --preload value              Comma separated list of JavaScript files to preload into the console
  --datadir "/root/.ethereum"  Data directory for the databases and keystore

So, I've tried to specify datadir after attach with no success:

[root@localhost ~]# geth -rinkeby attach --datadir="/root/.ethereum/rinkeby"
Fatal: Unable to attach to remote geth: dial unix /root/.ethereum/geth.ipc: connect: no such file or directory

And I think it's better to remove --datadir-- from flag fromattachand only leave it ingeth` to avoid ambiguity.

I'd like to fix this behavior and I'm asking you to check this first and confirm it's a bug.

Regards,
Ivan.

Most helpful comment

On MacOS, for testnet:

geth attach ipc:/Users/ekotysh/Library/Ethereum/testnet/geth.ipc

All 17 comments

Try using --ipcpath "/root/.ethereum/rinkeby/geth.ipc" as well on the attacher. That works for me on *nix systems.

Thanks for the answer but that was exactly what I did then and this issue is not a request for advice but rather a possible bug report as this behavior doesn't seem logical.

+1. Replicated on MacOS here.
Used the cmd from the readme, geth --testnet --fast --cache=512 console
Cant attach to local running geth instance using geth attach. Also I cant seem to find this geth.ipc file anywhere.
Also the initial console is pretty unusable since it continues to sync on top.

@geth attach--ipcpath ".ethereum/geth.ipc" worked for me i am using the default path.

If you are using the testnet, you have to include the testnet folder on the path, for example on a mac:
geth attach ipc:$HOME/Library/Ethereum/geth.ipc on mac

Connected to the local RPC port worked for me:

geth attach http://localhost:8545

On MacOS, for testnet:

geth attach ipc:/Users/ekotysh/Library/Ethereum/testnet/geth.ipc

geth attach --datadir=... now works on the master branch (ethereum/go-ethereum#15517 added it). It will be part of geth 1.8.0.

I couldn't connect localhost 8545....
Is it changed?

this works for me on windows

geth attach "\.\pipe\whatever.ipc" or
geth attach "http://localhost:8546"

note that I started my node with ipcpath "whatever.ipc" and rpcport 8546

I believe it would work on other OS. Basically the parameter of the 'attach' would be a full url that would be used for fileopen equivalent.

The convention is inconsistent(where when starting geth, I cannot put \.\pipe\ as part of the path, though so long you know what you are doing, it should work

On macOS 10.12.6, using Geth/v1.7.3-stable/darwin-amd64/go1.9.2

First I set up a Private Network and started the Geth Node:

geth --datadir=./chaindata/ init ./genesis.json;
geth --datadir=/Users/Ls/code/blockchain/geth-node/chaindata/

Then I opened another Bash terminal window and tried to connect with JavaScript RPC Geth Console using the flags that were shown with geth attach --help, but only geth attach "/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc" actually worked:

$ geth attach --datadir "/Users/Ls/code/blockchain/geth-node/chaindata"
Fatal: Unable to attach to remote geth: dial unix /Users/Ls/Library/Ethereum/geth.ipc: connect: no such file or directory

$ geth attach ipc:/Users/Ls/code/blockchain/geth-node/chaindata
Fatal: Unable to attach to remote geth: dial unix /Users/Ls/code/blockchain/geth-node/chaindata: connect: socket operation on non-socket

$ geth attach "/Users/Ls/code/blockchain/geth-node/chaindata/geth.ipc"  
Welcome to the Geth JavaScript console!

instance: Geth/v1.7.3-stable/darwin-amd64/go1.9.2
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> web3.eth.accounts
[]

I have shared my code and an explanation here: https://github.com/ltfschoen/geth-node

Some additions for those who use eth instead of geth.
This combination is worked for me on Windows 8

... --ipcpath "node1.ipc"
geth attach ".\pipe\node1.ipcgeth.ipc"

@antonmok
@ltfschoen

sigh, all these convention things, developers are really not interested in documenting the details(which I can understand as I am also one, it works for me and my time is tight) :-)

Worked on macOS High Sierra 10.13.3

  1. run geth in developer move with mining enebled(this window needs to stay open and running): geth --dev -mine

This will start a peer-to-pear node and begin writing to a location on your drive. Mine is: _INFO [02-22|22:05:37] IPC endpoint opened: /var/folders/pd/q90qnj416350xv7g9kpmglt40000gq/T/geth.ipc_

  1. in a different command line terminal window run (replace path with yours): geth attach "/var/folders/pd/q90qnj416350xv7g9kpmglt40000gq/T/geth.ipc"

If you get a permission issue then run with a sudo command at the beginning like so:
sudo geth attach "/var/folders/pd/q90qnj416350xv7g9kpmglt40000gq/T/geth.ipc"

Hope this works for you :-)

As noted above, I used the local host specification and it worked.
My setup is for a private network with a common/host linux machine

1) In terminal 1 use
geth --rpc

2) In terminal 2 use
geth attach http://localhost:8545

Seems resolved, no?

Connected to the local RPC port worked for me:
geth attach http://localhost:8545

Got a permission error for "localhost", but geth attach http://127.0.0.1:8545 finally made it work. Thank you!
(using the latest geth docker image)

Was this page helpful?
0 / 5 - 0 ratings