<p>Instead of <code>getblockcount</code>, you can call <code>getblockchaininfo</code> and read the <code>headers</code> field.</p>

<p>However, while this may give you a lot more blocks than the local block count, you will still only receive a count up to the point where your node has synced headers (which can be limited by time, network, how well synced your peers are)</p>

<p>There is no way to always get the latest block height reliably from an unsynced node. </p>

CC BY-SA 4.0
2018-07-01T22:07:39.250Z
One could additionally check the timestamp in order to at least know whether this is a recent block.
Murch
CC BY-SA 3.0
2018-04-04T01:49:03.043Z
2018-04-04T01:49:03.043Z
Raghav Sood
<blockquote>
  <p>Of course this is last block in my device, but I want the real last block.</p>
</blockquote>

<p>There is no such thing. If there was a "real last block" that was clearly and unambiguously determinable, we would not need a blockchain.</p>

<p>The best you can do is run a node, and ask the node what's the best block it knows about. Or you can trust someone to run such a node and ask them.</p>

<p>Perhaps another way of seeing it: there is no distinction between a <em>synced</em> or <em>unsynced</em> node. Your node is <strong>always</strong> trying to synchronize with whatever other nodes in the network tell it. It can't know what the actual latest/best block on the network is, as at the very least the speed of light around the globe is limited.</p>

CC BY-SA 4.0
2018-06-19T20:12:36.623Z
2018-06-19T20:12:36.623Z
Pieter Wuille
<p>You would have to try to connect live nodes to get that information.</p>

<p><a href="https://bitnodes.earn.com/nodes/?q=United%20States" rel="nofollow noreferrer">https://bitnodes.earn.com/nodes/?q=United%20States</a></p>

<p>Lists active nodes of BTC network.</p>

<p>You should find some node which allows RPC connection on the port.</p>

CC BY-SA 3.0
2018-04-03T15:39:50.887Z
2018-04-03T15:39:50.887Z
VJV
<p>I have this code:</p>

<pre><code>from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
rpc_user='-------' #User name is hidden
rpc_password='-------' #Password hidden
logging.basicConfig()
logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG)
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%(rpc_user, rpc_password))
blockcount=rpc_connection.getblockcount()
print(blockcount)
</code></pre>

<p>The result:</p>

<pre><code>DEBUG:BitcoinRPC:-1-&gt; getblockcount []
DEBUG:BitcoinRPC:&lt;-1- 94768
94768
</code></pre>

<p>Of course this is last block in my device, but I want the real last block.</p>

<p>Is there a "external server or a Web site" i can call instead of Local server '127.0.0.1'? (for sending the bitcoin RBC method)</p>

<bitcoin-core><bitcoind><json-rpc><bitcoin-cli><node.js>
get the real last block
asd2791
# get the real last block

(Asked by: username_0 on 2018-04-03)

I have this code:

```
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
rpc_user='-------' #User name is hidden
rpc_password='-------' #Password hidden
logging.basicConfig()
logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG)
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%(rpc_user, rpc_password))
blockcount=rpc_connection.getblockcount()
print(blockcount)

```

The result:

```
DEBUG:BitcoinRPC:-1-> getblockcount []
DEBUG:BitcoinRPC:<-1- 94768
94768

```

Of course this is last block in my device, but I want the real last block.

Is there a "external server or a Web site" i can call instead of Local server '127.0.0.1'? (for sending the bitcoin RBC method)

**Tags:** bitcoin-core, bitcoind, json-rpc, bitcoin-cli, node.js


---

## 3 answers

### Answer by username_1 on 2018-04-04. Score: 3

Instead of `getblockcount`, you can call `getblockchaininfo` and read the `headers` field.

However, while this may give you a lot more blocks than the local block count, you will still only receive a count up to the point where your node has synced headers (which can be limited by time, network, how well synced your peers are)

There is no way to always get the latest block height reliably from an unsynced node.

> **Comments:**
> **username_2**: One could additionally check the timestamp in order to at least know whether this is a recent block.  

---

### Answer by username_3 on 2018-06-19. Score: 0

> Of course this is last block in my device, but I want the real last block.

There is no such thing. If there was a "real last block" that was clearly and unambiguously determinable, we would not need a blockchain.

The best you can do is run a node, and ask the node what's the best block it knows about. Or you can trust someone to run such a node and ask them.

Perhaps another way of seeing it: there is no distinction between a *synced* or *unsynced* node. Your node is **always** trying to synchronize with whatever other nodes in the network tell it. It can't know what the actual latest/best block on the network is, as at the very least the speed of light around the globe is limited.


---

### Answer by username_4 on 2018-04-03. Score: 0

You would have to try to connect live nodes to get that information.

<https://bitnodes.earn.com/nodes/?q=United%20States>

Lists active nodes of BTC network.

You should find some node which allows RPC connection on the port.


---

