Author

Topic: Unable to connect to Bitcoind [regtest] with curl (Read 111 times)

legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
Sorry about this, I changed the username to include the password like this username:password and now it works!

Basically, you always have to use --user username:password format when making a JSON-RPC request to bitcoind, otherwise, you will get a 401 Unauthorized error from it because it wants you to input the password using the Authorization header. Also see the results in https://github.com/bitcoin/bitcoin/search?q=HTTP_UNAUTHORIZED.
newbie
Activity: 6
Merit: 3
Sorry about this, I changed the username to include the password like this username:password and now it works!
newbie
Activity: 6
Merit: 3
Hi There,

This is my bitcoin.conf:

Code:
[regtest]
rpcuser=bitcoin
rpcpassword=talk

Running the below command gives me the suitable curl equivalent:

Code:
 ./bitcoin-cli -regtest help getbalances

Code:
Examples:
> bitcoin-cli getbalances
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getbalances", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Now, when I run the above curl command, I get a non response like this:
Code:
~/Desktop/bitcoin-0.21.1/bin  curl --user bitcoin --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }'  -H 'content-type: text/plain;'  http://127.0.0.1:18443
Enter host password for user 'bitcoin':

                                                                                                                                                                 
 ~/Desktop/bitcoin-0.21.1/bin 


Any idea on what is causing the refusal of the connection? I am running Mac and can see port 18443 taking connections

Thanks again.
Jump to: