Bitcoin Forum
November 25, 2025, 05:24:41 AM *
News: Latest Bitcoin Core release: 30.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Unable to connect to Bitcoind [regtest] with curl  (Read 113 times)
decent1984 (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 3


View Profile
August 08, 2021, 08:45:29 PM
Last edit: August 08, 2021, 09:20:31 PM by decent1984
 #1

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.
decent1984 (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 3


View Profile
August 08, 2021, 09:52:53 PM
 #2

Sorry about this, I changed the username to include the password like this username:password and now it works!
NotATether
Legendary
*
Offline Offline

Activity: 2156
Merit: 9108


Trêvoid █ No KYC-AML Crypto Swaps


View Profile WWW
August 09, 2021, 04:03:00 AM
 #3

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.

.
 betpanda.io 
 
ANONYMOUS & INSTANT
.......ONLINE CASINO.......
▄███████████████████████▄
█████████████████████████
█████████████████████████
████████▀▀▀▀▀▀███████████
████▀▀▀█░▀▀░░░░░░▄███████
████░▄▄█▄▄▀█▄░░░█▄░▄█████
████▀██▀░▄█▀░░░█▀░░██████
██████░░▄▀░░░░▐░░░▐█▄████
██████▄▄█░▀▀░░░█▄▄▄██████
█████████████████████████
█████████████████████████
█████████████████████████
▀███████████████████████▀
▄███████████████████████▄
█████████████████████████
██████████▀░░░▀██████████
█████████░░░░░░░█████████
███████░░░░░░░░░███████
████████░░░░░░░░░████████
█████████▄░░░░░▄█████████
███████▀▀▀█▄▄▄█▀▀▀███████
██████░░░░▄░▄░▄░░░░██████
██████░░░░█▀█▀█░░░░██████
██████░░░░░░░░░░░░░██████
█████████████████████████
▀███████████████████████▀
▄███████████████████████▄
█████████████████████████
██████████▀▀▀▀▀▀█████████
███████▀▀░░░░░░░░░███████
██████░░░░░░░░░░░░▀█████
██████░░░░░░░░░░░░░░▀████
██████▄░░░░░░▄▄░░░░░░████
████▀▀▀▀▀░░░█░░█░░░░░████
████░▀░▀░░░░░▀▀░░░░░█████
████░▀░▀▄░░░░░░▄▄▄▄██████
█████░▀░█████████████████
█████████████████████████
▀███████████████████████▀
.
SLOT GAMES
....SPORTS....
LIVE CASINO
▄░░▄█▄░░▄
▀█▀░▄▀▄░▀█▀
▄▄▄▄▄▄▄▄▄▄▄   
█████████████
█░░░░░░░░░░░█
█████████████

▄▀▄██▀▄▄▄▄▄███▄▀▄
▄▀▄█████▄██▄▀▄
▄▀▄▐▐▌▐▐▌▄▀▄
▄▀▄█▀██▀█▄▀▄
▄▀▄█████▀▄████▄▀▄
▀▄▀▄▀█████▀▄▀▄▀
▀▀▀▄█▀█▄▀▄▀▀

Regional Sponsor of the
Argentina National Team
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!