<p>I'm running a Bitcoin testnet node on a Ubuntu 22.04 VM using UTM for Macbooks M1.</p>
<p>I'm trying to connect via json-rpc using <a href="https://github.com/jgarzik/python-bitcoinrpc" rel="nofollow noreferrer">https://github.com/jgarzik/python-bitcoinrpc</a>.</p>
<p>1 - I installed the package etc..</p>
<p>2 - I edited my .conf file in <code>/home/kk/snap/bitcoin-core/common/.bitcoin/bitcoin.conf</code>:</p>
<pre><code>server=1
testnet=1
daemon=1
prune=1000
fallbackfee=0.00001
rpcuser=kk
rpcpassword=testpass
rpcallowip=127.0.0.1
[test]
rpcbind=127.0.0.1
rpcport=18332
</code></pre>
<p>3 - I created a file called &quot;btcrpc.py&quot;:</p>
<pre class="lang-python prettyprint-override"><code>from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from print import pprint

# rpc_user and rpc_password are set in the bitcoin. conf file
rpc_user = &quot;kk&quot;
rpc_pass = &quot;testpass&quot;
rpc_host = &quot;127.0.0.1&quot;
rpc_client = AuthServiceProxy(f'http://frpc_user}:{rpc_pass}@{rpc_host}:18332&quot;, timeout=120)

block_count = rpc_client.getblockcount()
print (block_count)
</code></pre>
<p>When I run btcrpc.py that's the error:</p>
<p><a href="https://i.sstatic.net/RMcte.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RMcte.png" alt="Why is it unauthorized?" /></a></p>
<p>What am I doing wrong?</p>

<bitcoin-core><json-rpc>
401 unauthorized connection using python-bitcoinrpc
Fawkes
# 401 unauthorized connection using python-bitcoinrpc

(Asked by: username_0 on 2022-10-22)

I'm running a Bitcoin testnet node on a Ubuntu 22.04 VM using UTM for Macbooks M1.
I'm trying to connect via json-rpc using https://github.com/jgarzik/python-bitcoinrpc.
1 - I installed the package etc..
2 - I edited my .conf file in /home/kk/snap/bitcoin-core/common/.bitcoin/bitcoin.conf:
server=1
testnet=1
daemon=1
prune=1000
fallbackfee=0.00001
rpcuser=kk
rpcpassword=testpass
rpcallowip=127.0.0.1
[test]
rpcbind=127.0.0.1
rpcport=18332

3 - I created a file called "btcrpc.py":
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from print import pprint

# rpc_user and rpc_password are set in the bitcoin. conf file
rpc_user = "kk"
rpc_pass = "testpass"
rpc_host = "127.0.0.1"
rpc_client = AuthServiceProxy(f'http://frpc_user}:{rpc_pass}@{rpc_host}:18332", timeout=120)

block_count = rpc_client.getblockcount()
print (block_count)

When I run btcrpc.py that's the error:

What am I doing wrong?

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


---

## 0 answers

