20

I can not figure out how to stop a running geth node without killing the process. I tried to lookup geth help but there is no mention of stopping, halting or any shutdown command.

How to shutdown geth cleanly?

Edit:

I'm running it as a daemon, CTRL+C is no option.

  • And how do I stop it if the Wallet crashed and Geth is still running as task in Windows? I use the task manager and stop the task but I fear it could harm something (even so it looks like it did not when I had to use it several times before). – Uwe G. Aug 13 '17 at 11:58
23

Because you ran geth as a daemon you can either:

killall -HUP geth

in one line, or get the pid with:

ps ax | grep geth

and kill it with kill

kill -HUP <pid>

-HUP is the sighup signal, is optional but is more gentle than the normal TERM signal.

  • 1
    +1 for using -HUP. – Afr Jan 29 '16 at 7:21
  • 1
    Instead of running ps and piping it to grep, you can use pgrep geth. One-liner: kill -HUP $(pgrep geth). – Diti Aug 13 '17 at 12:36
  • Or even pkill -HUP geth – carver Feb 27 '18 at 22:55
  • It continuously resurrect after kill – creator Apr 27 '18 at 7:40
11

use Ctrl c or

kill -INT <pid>

if you started geth with console, you exit with Ctrl D or

> exit
  • 5
    Is there really no command to stop a node? – Afr Jan 27 '16 at 16:57
  • @5chdn if your already in console, its fast to do Ctrl+c than opening up a new terminal tab to kill this. – niksmac Jul 17 '16 at 2:45
  • @5chdn I hear you bro. Something like bitcoin-cli stop, right? One would think that Ctrl+C or pkill don't let the program close well, but maybe they do? – e18r Jun 8 '17 at 18:46
7

When running in console

Geth can be stopped by sending it a keyboard interrupt with Ctrl + c. You should see output similar to the following.

I0127 09:46:49.971487   62813 blockchain.go:1230] imported 1 block(s) (0 queued 0 ignored) including 0 txs in 2.836192ms. #913170 [2eb50f50 / 2eb50f50]
^C
I0127 09:46:54.258683   62813 cmd.go:123] Got interrupt, shutting down...
I0127 09:46:54.259731   62813 blockchain.go:677] Chain manager stopped
I0127 09:46:54.259774   62813 handler.go:191] Stopping ethereum protocol handler...
I0127 09:46:54.259797   62813 handler.go:201] Ethereum protocol handler stopped
I0127 09:46:54.259813   62813 transaction_pool.go:150] Transaction pool stopped
I0127 09:46:54.259831   62813 backend.go:630] Automatic pregeneration of ethash DAG OFF (ethash dir: /home/user/.ethash)
I0127 09:46:54.260551   62813 database.go:158] closed db: /home/user/.ethereum/chaindata
I0127 09:46:54.260716   62813 database.go:158] closed db: /home/user/.ethereum/dapp

In the event that go-ethereum receives multiple interrupts before shutting down cleanly, you should see something like this.

I0127 09:50:47.173412   63063 cmd.go:129] Already shutting down, please be patient.
I0127 09:50:47.173433   63063 cmd.go:130] Interrupt 9 more times to induce panic.

In this case if you continue to hit Ctrl + c to force the process to quit you may corrupt the underlying databases that go-ethereum maintains.

Killing a Daemon Process

If the process is running as a daemon, then you can kill it with kill -INT <pid> where <pid is the process id for the running geth process.

One way to find the process id is with ps aux | grep geth.

$ ps aux | grep geth
user           63353  91.2  0.2 573457444  29844 s019  R+   10:15AM   0:01.97 geth --rpc
user           63355   0.0  0.0  2434836    780 s021  S+   10:15AM   0:00.00 grep geth

Here the pid that should be killed is 63353.

  • 2
    CTRL+C is no option, geth runs as daemon. – Afr Jan 27 '16 at 16:56
  • Updated with info on killing a daemon process. – Piper Merriam Jan 27 '16 at 17:16
2

Simply use

pkill -INT geth

which will reuslt in the same as pressing CTRL-C in geth console:

...
INFO [01-13|12:17:53] Imported new chain segment...
INFO [01-13|12:17:57] Got interrupt, shutting down... 
INFO [01-13|12:17:57] HTTP endpoint closed: http://...:8545 
INFO [01-13|12:17:57] IPC endpoint closed: /.../.ethereum/geth.ipc 
INFO [01-13|12:17:57] Blockchain manager stopped 
INFO [01-13|12:17:57] Stopping Ethereum protocol 
0

Ctrl D and then exit worked for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.