|
Title: Unable to connect to Bitcoind [regtest] with curl Post by: decent1984 on August 08, 2021, 08:45:29 PM Hi There,
This is my bitcoin.conf: Code: [regtest] Running the below command gives me the suitable curl equivalent: Code: ./bitcoin-cli -regtest help getbalances Code: Examples: 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:18443Any idea on what is causing the refusal of the connection? I am running Mac and can see port 18443 taking connections Thanks again. Title: Re: Unable to connect to Bitcoind [regtest] with curl Post by: decent1984 on August 08, 2021, 09:52:53 PM Sorry about this, I changed the username to include the password like this username:password and now it works!
Title: Re: Unable to connect to Bitcoind [regtest] with curl Post by: NotATether on August 09, 2021, 04:03:00 AM 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. |