I used the following code to connect to the bitcoin core client and encountered this error:

bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server

My configuration file: bitcoin.conf is written as follows:

Expose the RPC/JSON API


May I ask what caused my code to report an error, and how should I solve this problem?

  • This error can depend also from the library/method that you are using to talk with the RPC interface Commented May 18, 2021 at 10:17
  • Why do you wrap stuff on quotes needlessly?
    – Mercedes
    Commented Oct 24, 2021 at 11:47

1 Answer 1


There are many things that can be wrong. More details are required, like the code you mentioned.

There is a more thorough discussion on this matter here:


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.