<p>I am new to python-bitcoinrpc(also new to VM Linux actually) and I want to use the blockchain parser from <a href="https://github.com/alecalve/python-bitcoin-blockchain-parser" rel="nofollow noreferrer">alecalve</a> to get ordered blocks. I used Windows to download the blockchain data into an external hard drive as well as <code>bitcoin.conf</code> but then I found that this parser could only be used on Linux, so I downloaded Bitcoin Core again on Linux and run</p>

<pre><code>./bitcoin-qt -datadir=/media/myharddrive/Bitcoin -conf=/media/myharddrive/Bitcoin/bitcoin.conf
</code></pre>

<p>to avoid re-downloading the data.</p>

<p>However, it seems I cannot connect to rpc because the simple code</p>

<pre><code>rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%('rpcuser', 'myrpcpassword'))

best_block_hash = rpc_connection.getbestblockhash()
</code></pre>

<p>returns error like this</p>

<pre><code>Traceback (most recent call last):
  File "process1.py", line 129, in &lt;module&gt;
    parser(block)
  File "process1.py", line 62, in parser
    prevtxhex = rpc_connection.getrawtransaction(prevtxidhash,0)
  File "/home/lylian/.local/lib/python3.8/site-packages/bitcoinrpc/authproxy.py", line 132, in __call__
    self.__conn.request('POST', self.__url.path, postdata,
  File "/usr/lib/python3.8/http/client.py", line 1230, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1276, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1225, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1004, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 944, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 915, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
</code></pre>

<p>I wonder if it's because my code cannot find bitcoin.conf(I put it both in the default location and my hard drive) or there is something wrong with my settings.</p>

<pre><code>rpcuser=xxx
rpcpassword=xxx
server=1
</code></pre>

<p>Thanks very much!!</p>

CC BY-SA 4.0
2020-04-30T17:59:17.647Z
can you upload also your bitcoin.conf?
vincenzopalazzo
CC BY-SA 4.0
2020-05-01T02:05:33.507Z
already did, it's just simple...
Lylian
CC BY-SA 4.0
2020-05-01T03:55:23.873Z
add `rpcuser=sandbox` , `rpcpassword=sendbox`, `rpcport=8332` `bind=127.0.0.1` and you can use this python script [to test](https://gist.github.com/vincenzopalazzo/1f1245ab200ed59a0604dee134f42863) the node with python
vincenzopalazzo
<bitcoin-core><json-rpc><python>
Connection refused when using bitcoinrpc on Linux
Lylian
# Connection refused when using bitcoinrpc on Linux

(Asked by: username_0 on 2020-04-29)

I am new to python-bitcoinrpc(also new to VM Linux actually) and I want to use the blockchain parser from [alecalve](https://github.com/alecalve/python-bitcoin-blockchain-parser) to get ordered blocks. I used Windows to download the blockchain data into an external hard drive as well as `bitcoin.conf` but then I found that this parser could only be used on Linux, so I downloaded Bitcoin Core again on Linux and run

```
./bitcoin-qt -datadir=/media/myharddrive/Bitcoin -conf=/media/myharddrive/Bitcoin/bitcoin.conf

```

to avoid re-downloading the data.

However, it seems I cannot connect to rpc because the simple code

```
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%('rpcuser', 'myrpcpassword'))

best_block_hash = rpc_connection.getbestblockhash()

```

returns error like this

```
Traceback (most recent call last):
  File "process1.py", line 129, in <module>
    parser(block)
  File "process1.py", line 62, in parser
    prevtxhex = rpc_connection.getrawtransaction(prevtxidhash,0)
  File "/home/username_0/.local/lib/python3.8/site-packages/bitcoinrpc/authproxy.py", line 132, in __call__
    self.__conn.request('POST', self.__url.path, postdata,
  File "/usr/lib/python3.8/http/client.py", line 1230, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1276, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1225, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1004, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 944, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 915, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

```

I wonder if it's because my code cannot find bitcoin.conf(I put it both in the default location and my hard drive) or there is something wrong with my settings.

```
rpcuser=xxx
rpcpassword=xxx
server=1

```

Thanks very much!!

**Tags:** bitcoin-core, json-rpc, python

> **Comments:**
> **username_1**: can you upload also your bitcoin.conf?  
> **username_0**: already did, it's just simple...  
> **username_1**: add `rpcuser=sandbox` , `rpcpassword=sendbox`, `rpcport=8332` `bind=127.0.0.1` and you can use this python script [to test](https://gist.github.com/username_1/1f1245ab200ed59a0604dee134f42863) the node with python  

---

## 0 answers

