Hey everyone, I could really use some help here.
Here's the issue: I’m trying to make a `curl` request, but I keep getting a "401 Unauthorized error".
I checked the debug log from the daemon, and it’s not giving me much to go on.
So, I started `bitcoind` like this:
Oh, and I also set up a symlink for my config:
My Config:
I generated `rpcauth` in this way and added it to the config:
I even tried swapping out `rpcauth` with this:
And I did
after each change to the config (not sure if that's really necessary).
Yeah, I have a "t" at the end of the password everywhere. I know it’s frustrating to keep that typo, but I copied and pasted the password a bunch of times, so I’m confident there are no mistakes when I respond to curl.
I’ve looked at these links for help:
https://bitcoin.stackexchange.com/questions/115668/401-unauthorized-connection-using-python-bitcoinrpc
https://bitcoin.stackexchange.com/questions/106395/bitcoinrpc-authproxy-jsonrpcexception-342-non-json-http-response-with-401-u
https://bitcoin.stackexchange.com/questions/36433/bitcoin-rpc-works-in-bitcoin-cli-but-not-in-python-bitcoinrpc-no-json-object
https://bitcoin.stackexchange.com/questions/77214/bitcoin-rpc-returning-401
I’m on Bitcoin Core version 25.0.
What am I missing here? Thanks a lot.
Getting 401 Unauthorized error when connecting to bitcoin-core with curl
8 replies 355 views
You are getting these errors because you are not passing in credentials when calling with CURL.
When you use JSON-RPC with CURL it doesn't matter whether the RPC method requires a wallet or not, if you have set an RPC username and password then you are required to pass them to curl or you will get a 401 error.
Just pass --user testuser:testpassword (NOT --user by itself)
or after http:// change the url to this 'testuser:testpassword@127.0.0.1:8332/'
Not exactly. When I do not give the password to `curl`, it asks directly:
You can see it in the very first code snippet in this thread.
Nevertheless, I have just tried: re-created and added the `rpcauth` string, sent -HUP, then tried
and
the same result, 401 Unauthorized.
And yes, the curl request was taken directly from the doc.
Anything else I can try here?
v4ult_d1amondMember
Posts: 38 · Reputation: 186
#4Feb 9, 2019, 10:28 PM
I searched your problem and this is one of the link that popped up. It's not the same problem as you got though
I know how it sounds, but it works now without any intervention from my side, using both `--user testuser` only and with password. Without adding `--http1.1`
The only idea I can think of is that the daemon reloads config not immediately but after some time.
Anyway, it's solved. Thanks to everyone who tried to help.
To my knowledge bitcoind only reads the config file when it starts. So, if you have to make changes, you should stop bitcoind gracefully (frankly, I'm not sure if your kill -HUP does initiate a graceful exit; I always use bitcoin-cli stop for a clean termination of bitcoind), make your changes to the config file and then restart the daemon.
I'm not aware of another method to trigger bitcoind to re-read its config file.
Some or even many unixoid daemons react on a HUP signal with a re-read of their config file. Maybe the OP thought it's the same for bitcoind when in fact it isn't. Nice find by ETFbitcoin with the cited Github issue. To allow a re-read of the config file likely opens a Pandora's box of cans of worms and a whole lot of problems with the proper internal states of bitcoind and that's why the devs dismissed the feature requests so far.
Not only "Don't trust, verify!" but also "Don't assume something is working, check to be sure!".
In Bitcoin Core's case specifically, a lot of settings don't make sense to change without a full reload of the client. Take datadir or txindex for example. You can't really change these at runtime without discarding the application state (former) or incurring a short but huge performance penalty (latter). Or what if you change the RPC url or authentication? Then you'd have to wait for existing RPC calls to finish - which may be long running like importmulti - or abort them.
SIGHUP reloading works best for simple programs, not those with complex states such as a full blockchain.
It was mentioned in the link sent by @pinggoki.
Re: reloading: yep, lessons learned.
?Reply
Sign in to reply to this topic
Related topics
- Issue with Bitcoin Core Wallet after power outage 8
- Transforming my wallet into an HD wallet bitcoin core 26 4
- bitcoin-qt sync issues and slow speeds 6
- Recovering a Bitcoin wallet and address 8
- Affordable quiet mini PC for running a Bitcoin node and blockchain explorer 19
- Using two different Bitcoin versions without messing up blockchain data 3