When I use the official installed bitcoind 0.18.1 everything works fine. I can use the bitcoin-cli with any comands and don't get any errors. After that when I compiled 0.18.1 myself I can't use any bitcoin-cli comands and I get:

error: Could not connect to the server Make sure the bitcoind server is running and that you are connecting to the correct RPC port.

I use bitcoin-cli without any options, just a: bitcoin-cli.exe getbalance or bitcoin-cli.exe stop

Here is my simple bitcoin.conf which I use with the both versions:


I compile it with MinGW-w64-i686-posix-sjlj on Win7 target platform and with boost 1.57, libdb 4.8.30, openssl 1.0.1, libevent 2.0.22 as a dependent libs. I tried to compile 0.16.1 verion with the same stack but error is a similar:

error : couldn't connect to server : unknown (code -1) (make sure server is running and you are connecting to the correct RPC port)

What is wrong with compiled version? I can't realise what I missed. The compilation went without any errors. May be I missed some ./configure options?

  • I tried to replace bitcoin-cli from installed version. When bitcoin-cli getbalance I get another errors: error: Could not connect to the server (error code 2 - "error while reading header, or invalid header") but bitcoin-cli stop works fine in this case. Aug 25, 2019 at 11:47

1 Answer 1


The problem was in libevent 2.0.22. It spoiled HTTP response from bitcoind every time. libevent 2.1.11 fixed this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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