I'm running a testnet node. I can use bitcoin-cli just fine:

>bitcoin-cli.exe getinfo
    "version" : 100000,
    "protocolversion" : 70002,
    "walletversion" : 60000,
[... snipped]

But when I run this python code:

from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging

rpc_user = "rpcuser"
rpc_password = "xxxxx"


rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8332/" % (rpc_user, rpc_password))

I get this error:

DEBUG:BitcoinRPC:-1-> getinfo []

Traceback (most recent call last):
  File "<path>\rawtransactiondemo\raw.py", line 11, in <module>
[... snipped]
  File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

This is my bitcoin.conf:


I'm using the python-bitcoinrpc library.

3 Answers 3


I added some code to debug what bitcoin was sending back - it turned out to be a 401 error.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<BODY><H1>401 Unauthorized.</H1></BODY>

Why was this triggered? If you look in my bitcoin.conf, and my python code, you can see that the username is different (bitcoinrpc vs. rpcuser). Changing that fixed it.

Anyways, if you get the error ValueError: No JSON object could be decoded, this might be your problem.


For anyone else finding this, and the problem was NOT a typo like in the accepted answer:

The issue for me was simply that I had my conf file in the wrong location.

I installed this on Ubuntu 20.04 and saved the conf file in /.bitcoin/bitcoin.conf, but it was looking in /home/user, which was actually ~.bitcoin/bitcoin.conf.

Saving the conf file in the correct location resolved everything. I could now use bitcoin-cli without sudo, and the python scripts using python-bitcoinrpc.


If you're using the testnet, rpcport should be 18332.

  • 3
    It's not required; you just need to use the same ports on both ends. In my bitcoin.conf, I set rpcport to 8332.
    – Nick ODell
    Mar 13, 2015 at 14:15
  • @NickODell That would explain my testnet connectivity issues; I didn't realize the conf rpcport=8332 flag set port 8332 for mainnet AND testnet Mar 15, 2015 at 10:42

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.