Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to attach to the local running geth node #14536

Closed
tiabc opened this issue May 28, 2017 · 17 comments
Closed

Unable to attach to the local running geth node #14536

tiabc opened this issue May 28, 2017 · 17 comments

Comments

@tiabc
Copy link

tiabc commented May 28, 2017

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…c7af23 td=506912
INFO [05-28|15:21:21] Loaded most recent local full block      number=264232 hash=98e342…c7af23 td=506912
INFO [05-28|15:21:21] Loaded most recent local fast block      number=264232 hash=98e342…c7af23 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 from attachand 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.

@Prism019
Copy link

Prism019 commented Jun 5, 2017

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

@tiabc
Copy link
Author

tiabc commented Jun 5, 2017

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.

@kaustavha
Copy link

+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.

@allan2327
Copy link

allan2327 commented Jun 30, 2017

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

@Dvisacker
Copy link

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

@SaltySousChef
Copy link

Connected to the local RPC port worked for me:

geth attach http://localhost:8545

@ekotysh
Copy link

ekotysh commented Nov 5, 2017

On MacOS, for testnet:

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

@fjl
Copy link
Contributor

fjl commented Dec 1, 2017

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

@mokkun3125
Copy link

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

@garyng2000
Copy link

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

@ltfschoen
Copy link

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

@antonmok
Copy link

antonmok commented Dec 29, 2017

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.ipc\geth.ipc"

@garyng2000
Copy link

@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) :-)

@programerone
Copy link

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 :-)

@EMCarrasco
Copy link

EMCarrasco commented Apr 10, 2018

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

@holiman
Copy link
Contributor

holiman commented Jan 22, 2019

Seems resolved, no?

@ratio91
Copy link

ratio91 commented Aug 28, 2019

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests