How to safely shutdown bitcoind ?

30

8

Surprised this one hasn't been asked yet.

But how / what is the recommended best practice for shutting down bitcoind ?

Right now I'm manually killing the process with either sudo kill {pid} or if this is failing (like just now) using sudo pkill -9 -f bitcoind

ManreeRist

Posted 2013-10-10T23:22:03.253

Reputation: 737

Answers

15

I guess using bitcoind stop. I recommend this approach as killing the process could end you up with a corrupted database, from what I have experienced. Use bitcoind --help for all options and bitcoind help for all JSON-RPC commands.

Jori

Posted 2013-10-10T23:22:03.253

Reputation: 1 522

Good thinking. Missed that.ManreeRist 2013-10-11T19:11:13.817

7This doesn't work anymore: Error: Command line contains unexpected token 'stop', see bitcoind -h for a list of options.. The correct way to stop bitcoind is bitcoin-cli-stop command (see the other answer with higher vote count).iaforek 2017-10-23T08:10:49.497

55

I'm not sure if bitcoind stop still works as RPC with newer releases, since somewhere in help sections it says RPC funcionality removed from bitcoind.

Try bitcoin-cli stop.

Aliakbar Ahmadi

Posted 2013-10-10T23:22:03.253

Reputation: 1 335

Does not work with my setup. I think first of all to be able to use bitcoin-cli you have to start bitcoind with option server=1. I did this and still bitcoin-cli getinfo is returning an error. So I suspect bitcoin-cli does not work properly. I have a process in top that is called bitcoin-init. I am not sure if this is the right process that should be active after I started bitcoind or if this some sort of initialisation process and since it uses 100% of my Raspberry CPU it might as well hang and this might be the root of the problem. I appreciate any input.Ben 2019-08-28T10:18:54.987

5Confirmed bitcoin-cli stop works in version 11.Jonathan Cross 2015-09-17T12:42:11.403

2Still works in 2017! Use this.iaforek 2017-10-23T08:14:27.450

does not work... I did ./xxxcoin-cli stop but nothing happen after that and ./xxxcoind also does not stopped.creator 2018-02-21T12:29:05.123

1Yes, it still works.Ken Sharp 2018-08-01T23:17:07.970

9

if you started it using 'bitcoind -daemon' and you are using version 10 or above, then use 'bitcoin-cli stop'

Sean Bradley

Posted 2013-10-10T23:22:03.253

Reputation: 401

Does not work for me. What could be the reason? Does the daemon need to be started as a server? Is bitcoin-init an initialisation process to bitcoind? Because that is my process in top.Ben 2019-08-28T10:22:54.020

2

Make sure you specify the same options that you normally use when running bitcoin, for example, if you use a different datadir:

cd C:\Program Files\Bitcoin\daemon
bitcoin-cli -datadir=C:\Bitcoin stop

Frank Forte

Posted 2013-10-10T23:22:03.253

Reputation: 121

2

In my case, It works that ./bitcoin-cli -regtest stop

Mike Min

Posted 2013-10-10T23:22:03.253

Reputation: 21

0

If using testnet, try ./bitcoin-cli -testnet stop

liaoming

Posted 2013-10-10T23:22:03.253

Reputation: 11

1./bitcoin-cli stop is enough0xb10c 2018-08-03T08:51:56.923

I don't know why this correct and the only working answer when on testnet was down-voted. ./bitcoin-cli stop is definitely not enough when running 0.18rc on testnet.Tony 2019-03-14T05:30:49.670