익명 06:15

bitcoin-cli can't connect to server

bitcoin-cli can't connect to server

I'm trying to put up a simple system for some penetration tests. I have an Ubuntu server 16.04.1 with apache2 and bitcoin. all running "Hiddn service" through tor (and bitcoind proxied 127.0.0.1:9050). Now, using easybitcoin.php , the apache shows getinfo, send receive, all good. but using bitcoin-cli nothing works! "couldn't connect to server"..

my bitcoin.conf is:
server=1
listen=1
proxy=127.0.0.1:9050
rpcuser=myuser
rpcpassword=mypassword

Any ideas why bitcoin-cli can't connect?



Top Answer/Comment:

I know this question is almost decade old but I just had a similar problem on two modern machines with Bitcoin Core 28.1.0 under Ubuntu Server 22.04.1 (x86) and Ubuntu 22.04.5 (Arm) and wasted like two hours playing Linux admin while the solution was (at least for me) really simple. So let me leave this answer here for others.

I was starting Bitcoin Core as a daemon on boot with crontab entry like this:

@reboot bitcoind -daemon

The daemon seemed to be working, it was synchronising blocks but upon executing commands locally e.g.

bitcoin-cli getblockcount

I was just getting errors:

error: timeout on transient error: Could not connect to the server 127.0.0.1:8332. (...)

and in debug.log I was finding:

Binding RPC on address 127.0.0.1 port 8123 failed.

What fixed this for me was simply delaying daemon start for a few seconds, by editing my crontab to look like this:

@reboot sleep 10 && bitcoind -daemon

No changes to bitcoin.conf, settings.json or a firewall required. Be aware that you may need to play with the sleep value. I had this issue on two machines, on one of them 5 seconds delay was enough, on another one I had to change it to 10.

I am not sure what is the actual underlying issue so if a visitor to this question knows - feel free to comment and share.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다