bitcoin: Bitcoind ThreadRPCServer authentication problems
Describe the issue
If I try to connect with bitcoin-cli or any other client I get 401. I use normal username/password and always get 401 (localhost and remote). Authentication over basic auth cookie via bitcoin-cli works.
debug.log Msg:
2017-02-01 06:59:45 ThreadRPCServer incorrect password attempt from 127.0.0.1:41472
bitcoin-cli Msg:
error: incorrect rpcuser or rpcpassword (authorization failed)
Can you reliably reproduce the issue?
If so, please list the steps to reproduce below:
- Configure bitcoind (with my config) and start bitcoind
- bitcoin-cli -rpcuser=REPLACED -rpcpassword=REPLACED -rpcconnect=127.0.0.1 -rpcport=8332 -datadir=/data/btc getinfo
Expected behaviour
Successful authentication
Actual behaviour
HTTP Code 401
What version of bitcoin-core are you using?
List the version number/commit ID, and if it is an official binary, self compiled or a distribution package such as PPA.
- Bitcoin Core Daemon version v0.13.2 Arch Linux distribution package
- Bitcoin Core Daemon version v0.13.99.0-e99f0d7ad self compiled
with wallet = yes
with gui / qt = yes
qt version = 5
with qr = yes
with zmq = yes
with test = yes
with bench = yes
with upnp = yes
debug enabled = no
Machine specs:
- OS: Arch Linux x64
- CPU: Xeon 4 cores 2 threads
- RAM: 16G
- Disk size: 16T RAID5
- Disk Type (HD/SDD): HD
Any extra information that might be useful in the debugging process.
This is normally the contents of a debug.log
or config.log
file. Raw text or a link to a pastebin type site are preferred.
My bitcoind config:
server=1
listen=1
rpcuser=REPLACED
rpcpassword=REPLACED
rpcbind=127.0.0.1:8332
rpcthreads=8
rpcallowip=127.0.0.1
HTTP request/response (from tcpdump):
POST / HTTP/1.1
Authorization: Basic UkVQTEFDRUQ6UkVQTEFDRUQ=
Host: REPLACED:8332
Accept: */*
Content-type: application/json
Content-Length: 39
{"method":"getinfo","params":[],"id":1}
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="jsonrpc"
Date: Wed, 01 Feb 2017 07:05:40 GMT
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (8 by maintainers)
I was running it on Ubuntu 16.
I had
rpcuser
andrpcpassword
in the config file, but I was getting 401 error when I called the jaon-rpc api.I found a workaround by providing
-rpcuser=REPLACED -rpcpassword=REPLACED
when I launched the bitcoind.Hope this is still relevant and useful.
@gr33k That’s an unrelated issue. Since 0.18 you need to put
rpcbind
explicitly if you want to listen on more than localhost.For future googlers: the password should not contain the pound sign (
#
) as this is treated as a comment!I am having this issue on my mac OSX High Sierra. The rpcuser and rpcpassword set in the conf file are not being used by the rpcserver.
Failure
Success
Can also be done via CLI
Failure
Sucess
On Windows, using Bitcoin Core 0.13.2, this works fine (rpc/rpc):
bitcoin-cli.exe -rpcuser=rpc -rpcpassword=rpc -testnet=1 getinfo
It’s either specific to your build or maybe some of the parameters and arguments have issues. Simple RPC-focused test without using config files: