I am running Bitcoin Network on local Ubuntu machine. The network consists of multiple nodes. I want to connect to the network from a java application running on the same machine via JSON RPC. I can connect to the Bitcoind server from command line using bitcoin-cli. However, i cannot connect to the Bitcoind server from the Java application using Bitcoinj Libraray. I suspect that the problem is related to RPC authentication. I specified rpc username and password in the bitcoin.conf file and I tried to use Java Authenticator in my Java code. However, it hasn't solved the problem.

  Authenticator.setDefault(new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication()
 { return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());

My bitcoin.conf file is as follows:


This is the log message I see when i start the Bitcoind server: Server Log

  • List item

Server Log

And this is the error I am receiving on the application side: Application side error message

I am using Bitcoin core version 22 for the server and Bitcoinj library version 16.1 (https://bitcoinj.org/getting-started) to connect to the server

  • Are you trying to connect to regtest? If so, you've specified a custom rpcport, does your Java code try to connect to that port?
    – Ava Chow
    Sep 2, 2022 at 20:28
  • @AndrewChow yes, i am trying to connect to a regtest network using the new rpcport I specified in the bitcoin.conf file.
    – J.A
    Sep 3, 2022 at 8:39
  • Is there anyone who can help with this issue? @AndrewChow Any idea? Thanks
    – J.A
    Nov 6, 2022 at 10:22

1 Answer 1


The issue is that you are trying to connect BitcoinJ to Bitcoin Core's RPC interface. However BitcoinJ is not a RPC client, it's a separate node(ish) implementation that connects to other nodes using the P2P protocol. The P2P interface and the RPC interface are separate and use different protocols, you cannot connect one to the other and expect them to work.

This issue can be solved by having BitcoinJ connect to port 10000 as that is the port that you have configured Bitcoin Core to listen on for P2P connections.

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.