<p>Starting to interface with my btc node and I'm getting an RPC error 401 unoathorized error when running the below code.  My RPC_Auth (rpcuser:rpcpassword) is correct.  Is there something else I need to configure?  Any help would be appreciated.</p>
<pre><code>rpc_url = f&quot;http://{rpc_auth}@{rpc_host}:{rpc_port}&quot;
rpc_client = AuthServiceProxy(rpc_url, timeout=120)

try:

    peer_info = rpc_client.getpeerinfo()
    print(peer_info)
except JSONRPCException as e:
    print(f&quot;RPC Error: {e}&quot;)
</code></pre>

CC BY-SA 4.0
2023-09-07T20:53:36.827Z
When you set `rpcuser` and `rpcpassword` in your `bitcoin.conf`, did you also restart Bitcoin Core so that those changes apply?
Ava Chow
CC BY-SA 4.0
2023-09-08T02:50:11.980Z
I set rpcauth using the rpcauth.py file during my IBD so that hasnt changed.
chump365
CC BY-SA 4.0
2023-09-08T19:12:57.850Z
https://bitcoin.stackexchange.com/questions/46782/rpc-cookie-authentication helped answer all my questions and get this figured out.
chump365
<json-rpc>
Accessing RPC with RPC Auth or .cookie
chump365
# Accessing RPC with RPC Auth or .cookie

(Asked by: username_0 on 2023-09-07)

Starting to interface with my btc node and I'm getting an RPC error 401 unoathorized error when running the below code.  My RPC_Auth (rpcuser:rpcpassword) is correct.  Is there something else I need to configure?  Any help would be appreciated.
rpc_url = f"http://{rpc_auth}@{rpc_host}:{rpc_port}"
rpc_client = AuthServiceProxy(rpc_url, timeout=120)

try:

    peer_info = rpc_client.getpeerinfo()
    print(peer_info)
except JSONRPCException as e:
    print(f"RPC Error: {e}")

**Tags:** json-rpc

> **Comments:**
> **username_1**: When you set `rpcuser` and `rpcpassword` in your `bitcoin.conf`, did you also restart Bitcoin Core so that those changes apply?  
> **username_0**: I set rpcauth using the rpcauth.py file during my IBD so that hasnt changed.  
> **username_0**: https://bitcoin.stackexchange.com/questions/46782/rpc-cookie-authentication helped answer all my questions and get this figured out.  

---

## 0 answers

