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

CC BY-SA 4.0
2019-08-26T20:58:45.013Z
2019-08-27T08:00:02.413Z
2019-08-27T08:00:02.413Z
javierMarquez
<p>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:</p>

<blockquote>
  <p>error: Could not connect to the server 127.0.0.1:8332
  Make sure the bitcoind server is running and that you are connecting to the correct RPC port.</p>
</blockquote>

<p>I use bitcoin-cli without any options, just a: <code>bitcoin-cli.exe getbalance</code> or <code>bitcoin-cli.exe stop</code> </p>

<p>Here is my simple bitcoin.conf which I use with the both versions:</p>

<pre><code>server=1
rpcuser=username
rpcpassword=password
rpcallowip=127.0.0.1
rpcport=8332
datadir=F:\BitcoinData
</code></pre>

<p>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:</p>

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

<p>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?</p>

CC BY-SA 4.0
2019-08-25T11:47:27.200Z
I tried to replace bitcoin-cli from installed version. When `bitcoin-cli getbalance` I get another errors: `error: Could not connect to the server 127.0.0.1:8332 (error code 2 - "error while reading header, or invalid header")` but  `bitcoin-cli stop` works fine in this case.
javierMarquez
<bitcoind><json-rpc><bitcoin-cli><compiling>
Compiled version of bitcoind 0.18.1. "Could not connect to the server 127.0.0.1:8332"
javierMarquez
# Compiled version of bitcoind 0.18.1. "Could not connect to the server 127.0.0.1:8332"

(Asked by: username_0 on 2019-08-25)

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 127.0.0.1:8332
> 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:

```
server=1
rpcuser=username
rpcpassword=password
rpcallowip=127.0.0.1
rpcport=8332
datadir=F:\BitcoinData

```

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?

**Tags:** bitcoind, json-rpc, bitcoin-cli, compiling

> **Comments:**
> **username_0**: I tried to replace bitcoin-cli from installed version. When `bitcoin-cli getbalance` I get another errors: `error: Could not connect to the server 127.0.0.1:8332 (error code 2 - "error while reading header, or invalid header")` but  `bitcoin-cli stop` works fine in this case.  

---

## 1 answers

### Answer by username_0 on 2019-08-26. Score: 1 | Accepted answer

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


---

