<p>Here's a script doing just that:</p>

<pre><code>echo `bitcoin-cli getblockcount 2&gt;&amp;1`/`wget -O - https://blockchain.info/q/getblockcount 2&gt;/dev/null`
</code></pre>

CC BY-SA 3.0
2013-04-04T10:29:14.707Z
2017-08-15T05:38:26.860Z
2017-08-15T05:38:26.860Z
o0'.
<p>Run <code>bitcoind getblocktemplate</code>. If you're not caught up, then it will come back with an error of <code>-10</code>.</p>

CC BY-SA 3.0
2013-04-05T02:27:13.863Z
I checked this, it's not so. (I checked it on the testnet network though, but should not be different that mainnet in this case.)
Steven Roose
CC BY-SA 3.0
2013-04-05T16:21:23.827Z
This is a slight hack, but it more or less works. Great :)
Karel Bílek
CC BY-SA 3.0
2014-11-17T18:28:23.800Z
@StevenRoose, what was the problem you found with this method? When did it not work? It seems to be working for me, erroring when I'm in the middle of downloading blocks.
morsecoder
CC BY-SA 3.0
2014-11-17T20:52:34.263Z
@StephenM347 it's been more than a year, probably there was an issue back then that has been resolved by now..
Steven Roose
CC BY-SA 3.0
2013-04-04T19:17:02.717Z
2014-11-18T05:22:10.367Z
2014-11-18T05:22:10.367Z
Nick ODell
<p>The <code>bitcoind</code> command shows different errors now.</p>

<p>The new way to check is with <code>bitcoin-cli getblocktemplate</code></p>

<p>Scripted use has been posted where I first ran accross this question</p>

<p><a href="https://bitcoin.stackexchange.com/questions/9068/how-to-check-if-the-block-chain-is-up-to-date-using-bitcoind-or-json-rpc/38347#38347">How to check if the block chain is up to date using bitcoind or json-rpc?</a></p>

CC BY-SA 3.0
2015-07-01T09:22:24.950Z
2015-07-01T09:22:24.950Z
2017-04-13T12:47:32.940Z
S0AndS0
<p>An alternative method, (working with recent versions), that does not depend on external websites, is to use <code>bitcoin-cli getblockchaininfo</code> and compare the <code>headers</code> field and the <code>blocks</code> field.</p>

<p>Currently, in order to sync the blockchain faster, headers are downloaded before the actual blocks. This is known as <em>Headers-First Sync</em>
As a consequence, the number of block headers during the Initial Block Download (IBD) will be higher than the number of blocks.
When this number "catches up" with the number of blocks, we can say we are "up to date" with the blockchain that our peers advertised to us.</p>

<p>I wrote a script to start bitcoind and outputs dots while still in IBD phase.
When the blockchain is up to date, it will output a message.
Here's the script:
<a href="https://github.com/frz-dev/btcutils/blob/master/bitcoin-core/start-bitcoind.sh" rel="nofollow noreferrer">https://github.com/frz-dev/btcutils/blob/master/bitcoin-core/start-bitcoind.sh</a></p>

CC BY-SA 4.0
2020-06-10T11:01:31.420Z
2020-06-10T11:01:31.420Z
FedFranz
<p>Simplest way is to run </p>

<pre><code>bitcoind -blocknotify myscript.sh %s
</code></pre>

<p>On the blocks after bitcoind catches up with the blockchain, your scripts will get called with the new blockhash. You can print a message or do anything else required in this script </p>

CC BY-SA 3.0
2015-07-03T07:13:39.287Z
2015-07-03T07:13:39.287Z
dark knight
<p>With only a Web browser, you can visit <a href="http://bitcoinwatch.com/" rel="nofollow">http://bitcoinwatch.com/</a> to discover the current Bitcoin Network's block height or count.</p>

<p>Or point your bitcoin-cli to a production Bitcoind server and issue the following command (note, the *.conf file should be the one you use instead):</p>

<p>% ../bin/bitcoin-cli -conf=mainNet-productionServer.conf getblockcount</p>

<p>The easiest way is to query all of your peer connections for numerous details that also includes the "startingheight" for each of them.</p>

<p>% ../bin/bitcoin-cli -conf=mainNet-localServer.conf getpeerinfo</p>

<p>Alternatively, the following libbitcoin-explorer command (bx, serves an analogous role as bitcoin-cli) provides only a single number when the bx client connects to a production <a href="https://wiki.unsystem.net/en/index.php/Obelisk/Servers" rel="nofollow">bitcoin-server</a> (previously called Obelisk) to query it for the Blockchain's height.</p>

<p>% bx fetch-height</p>

<p>To get the current height of your localServer that is being built try:</p>

<p>% ../bin/bitcoin-cli -conf=mainNet-localServer.conf getblockcount</p>

<p>For contrasting purposes, the following bitcoin-cli help command provides additional details to for your local Blockchain image you are building:</p>

<p>% ../bin/bitcoin-cli -conf=mainNet.conf help gettxoutsetinfo
gettxoutsetinfo</p>

<p>Returns statistics about the unspent transaction output set.
Note this call may take some time.</p>

<p>Result:
{
  <strong>"height":n</strong>,     (numeric) The current block height (index)
  "bestblock": "hex",   (string) the best block hash hex
  "transactions": n,      (numeric) The number of transactions
  "txouts": n,            (numeric) The number of output transactions
  "bytes_serialized": n,  (numeric) The serialized size
  "hash_serialized": "hash",   (string) The serialized hash
  "total_amount": x.xxx          (numeric) The total amount
}</p>

<p>Your blockchain is complete when the two numbers match. This approach will give you a good idea about your current status.</p>

CC BY-SA 3.0
2015-07-01T16:39:19.237Z
2015-07-02T03:19:17.820Z
2015-07-02T03:19:17.820Z
skaht
<p>Run <code>bitcoind getinfo</code> in your shell of choice and compare the block count, listed after "blocks", to the block count listed <a href="http://blockexplorer.com/q/getblockcount" rel="noreferrer">here</a>. If the two numbers are the same, your client is up to date.</p>

CC BY-SA 3.0
2012-08-10T06:50:41.333Z
2012-08-10T06:50:41.333Z
BinaryMage
<p>I'm using bitcoind on Ubuntu, headless. So there's no GUI to tell me when it's done.</p>

<p>So how do I know?</p>

<blockchain><synchronization>
When downloading the blockchain for the first time using bitcoind, how do I know when it's done?
Shamoon
# When downloading the blockchain for the first time using bitcoind, how do I know when it's done?

(Asked by: username_0 on 2012-08-09)

I'm using bitcoind on Ubuntu, headless. So there's no GUI to tell me when it's done.

So how do I know?

**Tags:** blockchain, synchronization


---

## 7 answers

### Answer by username_10 on 2012-08-10. Score: 5 | Accepted answer

Run `bitcoind getinfo` in your shell of choice and compare the block count, listed after "blocks", to the block count listed [here](http://blockexplorer.com/q/getblockcount). If the two numbers are the same, your client is up to date.


---

### Answer by username_1 on 2013-04-04. Score: 5

Here's a script doing just that:

```
echo `bitcoin-cli getblockcount 2>&1`/`wget -O - https://blockchain.info/q/getblockcount 2>/dev/null`

```


---

### Answer by username_2 on 2013-04-04. Score: 3

Run `bitcoind getblocktemplate`. If you're not caught up, then it will come back with an error of `-10`.

> **Comments:**
> **username_3**: I checked this, it's not so. (I checked it on the testnet network though, but should not be different that mainnet in this case.)  
> **username_4**: This is a slight hack, but it more or less works. Great :)  
> **username_5**: @username_3, what was the problem you found with this method? When did it not work? It seems to be working for me, erroring when I'm in the middle of downloading blocks.  
> **username_3**: @StephenM347 it's been more than a year, probably there was an issue back then that has been resolved by now..  

---

### Answer by username_6 on 2015-07-01. Score: 1

The `bitcoind` command shows different errors now.

The new way to check is with `bitcoin-cli getblocktemplate`

Scripted use has been posted where I first ran accross this question

[How to check if the block chain is up to date using bitcoind or json-rpc?](https://bitcoin.stackexchange.com/questions/9068/how-to-check-if-the-block-chain-is-up-to-date-using-bitcoind-or-json-rpc/38347#38347)


---

### Answer by username_7 on 2020-06-10. Score: 1

An alternative method, (working with recent versions), that does not depend on external websites, is to use `bitcoin-cli getblockchaininfo` and compare the `headers` field and the `blocks` field.

Currently, in order to sync the blockchain faster, headers are downloaded before the actual blocks. This is known as *Headers-First Sync*
As a consequence, the number of block headers during the Initial Block Download (IBD) will be higher than the number of blocks.
When this number "catches up" with the number of blocks, we can say we are "up to date" with the blockchain that our peers advertised to us.

I wrote a script to start bitcoind and outputs dots while still in IBD phase.
When the blockchain is up to date, it will output a message.
Here's the script:
<https://github.com/frz-dev/btcutils/blob/master/bitcoin-core/start-bitcoind.sh>


---

### Answer by username_8 on 2015-07-03. Score: 1

Simplest way is to run

```
bitcoind -blocknotify myscript.sh %s

```

On the blocks after bitcoind catches up with the blockchain, your scripts will get called with the new blockhash. You can print a message or do anything else required in this script


---

### Answer by username_9 on 2015-07-01. Score: 0

With only a Web browser, you can visit <http://bitcoinwatch.com/> to discover the current Bitcoin Network's block height or count.

Or point your bitcoin-cli to a production Bitcoind server and issue the following command (note, the \*.conf file should be the one you use instead):

% ../bin/bitcoin-cli -conf=mainNet-productionServer.conf getblockcount

The easiest way is to query all of your peer connections for numerous details that also includes the "startingheight" for each of them.

% ../bin/bitcoin-cli -conf=mainNet-localServer.conf getpeerinfo

Alternatively, the following libbitcoin-explorer command (bx, serves an analogous role as bitcoin-cli) provides only a single number when the bx client connects to a production [bitcoin-server](https://wiki.unsystem.net/en/index.php/Obelisk/Servers) (previously called Obelisk) to query it for the Blockchain's height.

% bx fetch-height

To get the current height of your localServer that is being built try:

% ../bin/bitcoin-cli -conf=mainNet-localServer.conf getblockcount

For contrasting purposes, the following bitcoin-cli help command provides additional details to for your local Blockchain image you are building:

% ../bin/bitcoin-cli -conf=mainNet.conf help gettxoutsetinfo
gettxoutsetinfo

Returns statistics about the unspent transaction output set.
Note this call may take some time.

Result:
{
**"height":n**, (numeric) The current block height (index)
"bestblock": "hex", (string) the best block hash hex
"transactions": n, (numeric) The number of transactions
"txouts": n, (numeric) The number of output transactions
"bytes\_serialized": n, (numeric) The serialized size
"hash\_serialized": "hash", (string) The serialized hash
"total\_amount": x.xxx (numeric) The total amount
}

Your blockchain is complete when the two numbers match. This approach will give you a good idea about your current status.


---

