My app interacts with remote Geth node through SSH. The first sended command was geth --cache=1024 When the node was sending back some sync logging information, the connection has been lost. Then I make a new session and send geth attach and think the node is running still. However it returns error:

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

Is it true geth deletes any sync files when it lose the current connection? And if it's false even, what happens when the Geth node terminates its running (for e.g. because of crash)?

1 Answer 1


If you are SSH-ing to your remote machine and then starting up geth --cache=1024 in the console, when your SSH connection drops out the geth command will terminate.

You can check if geth is still running by SSH-ing back to your machine and typing the command ps -ef | grep geth, for example:

Iota:ESE user$ ps -ef | grep geth
  501 37632   879   0  2:36pm ttys001    0:03.31 geth --rpc console
  501 37634  2685   0  2:36pm ttys002    0:00.01 grep geth

Once geth terminates, the geth.ipc file may be removed depending on whether the application terminates gracefully. This geth.ipc file is an interprocess communication pipe and not a regular file. Once geth terminates, the file may still remain on the file system, but other processes cannot communicate to geth using this pipe.

If geth terminates without gracefully shutting down, the blockchain data can sometimes (very seldom) be corrupted.

Following is a recipe if you want to keep geth running on your Ubuntu (assumed from your previous posts) machine. If you want to terminate this background geth process, use the command killall -q --signal SIGINT geth.

Recipe For Running geth Automatically On Startup

If you want geth to run on your remote machine all the time, here is a recipe, all to be done in the SSH session on your remote machine:

  1. Create a directory for your logs - I'm using $HOME/ethlogs.

    user@RemoteMachine:~$ mkdir $HOME/ethlogs
  2. Create a directory for your log archive - I'm using $HOME/logarchive.

    user@RemoteMachine:~$ mkdir $HOME/logarchive
  3. Create the file $HOME/bin/runGeth with the following contents:

    # Kill geth gracefully
    killall -q --signal SIGINT geth
    # Wait for geth to be killed gracefully
    sleep 30
    # Kill viciously if geth is still running
    killall -q geth
    # Remove the IPC pipe file if it still exists
    rm $HOME/.ethereum/geth.ipc
    DATE=`date +%Y%m%d_%H%M%S`
    # Save old log file into the log archive directory
    mv $HOME/ethlogs/geth.log $HOME/logarchive/geth.log_$DATE
    # Use 6 for full details
    # Add your geth command line parameters below
    geth --cache=1024 --verbosity $VERBOSITY 2>> $HOME/ethlogs/geth.log &
  4. Set the file's executable bit.

    chmod 700 $HOME/bin/runGeth
  5. Log out and then log back in so your $HOME/bin path is activated if it has not already been done.

  6. Run geth

    user@RemoteMachine:~$ runGeth
  7. If you want geth to automatically start after you reboot your machine, add the runGeth command to your /etc/rc.local file.

    user@RemoteMachine:~$ sudo vi /etc/rc.local

    and add the following line before the exit 0:

    sudo -u {your username} /home/{your username}/bin/runGeth &

    Save and exit the file. Try restarting your computer and use ps -ef | grep geth to check if geth is running.


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.