9

After starting bitcoin from the command line, with:

./bitcoind -daemon

I immediately run the followup command:

./bitcoind getinfo

which gives me the following error:

error: couldn't connect to server

This error lasts from a few seconds to a few minutes depending on the machine.

Two questions:

  1. What is Bitcoin doing during this time, that causes this error (i.e. prevents the client from returning the results of getinfo)?
  2. Are there any steps I can take that will minimize this start-up time?
11

The first thing Bitcoin-QT does is verify that the data stored on the disk is valid. Among other checks this includes verifying the last 288 blocks (the past two days in expectation). This task involves a large number of signature checks and will take some time to complete. Only after the startup checks have successfully completed will the connections to the Bitcoin Network be established and only then the client will start listening for incoming JSON-RPC requests.

  • 3
    another gotcha - I was running the testnet. couldn't get bitcoin-cli to work until I added -testnet (i.e. bitcoin-cli -testnet getinfo) – Peter Munnings Sep 14 '15 at 8:05
  • @PeterMunnings: Good one, thanks. I had the same problem -- although I'm about 90% sure that it used to work without it before. – Priidu Neemre Oct 1 '16 at 15:04
  • If you add testnet=1 to your main bitcoin.conf then the bitcoin-cli will work with testnet without having to specify it on the command line. Add -testnet=0 on the command line to bypass that for mainnet. – cdecker Oct 2 '16 at 13:02

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.