janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.52k stars 1.13k forks source link

Will not run on install - ECONNREFUSED #399

Closed ahuw closed 2 years ago

ahuw commented 2 years ago

Describe the bug

I have installed btc-rpc-explorer following https://raspibolt.org/btcrpcexplorer.html#btc-rpc-explorer but on npm run start I get errors

Environment (please complete the following information):

Configuration file content

server=1 txindex=1

listen=1 listenonion=1 proxy=127.0.0.1:9050 bind=127.0.0.1

rpcauth=**:*** zmqpubrawblock=tcp://127.0.0.1:28332 zmqpubrawtx=tcp://127.0.0.1:28333 whitelist=download@127.0.0.1 # for Electrs

maxconnections=40 maxuploadtarget=5000

BTCEXP_BITCOIND_HOST=newRaspberry.local BTCEXP_BITCOIND_PORT=8332

BTCEXP_BITCOIND_USER=

BTCEXP_BITCOIND_PASS=

BTCEXP_BITCOIND_COOKIE=/data/bitcoin/.cookie BTCEXP_BITCOIND_RPC_TIMEOUT=10000

BTCEXP_ADDRESS_API=electrum

BTCEXP_ELECTRUM_SERVERS=tcp://newRaspberry.local:50001

BTCEXP_PRIVACY_MODE=false

BTCEXP_NO_RATES=false BTCEXP_UI_THEME=dark

To Reproduce

Steps to reproduce the behavior: npm run start

btc-rpc-explorer@3.3.0 start /home/btcrpcexplorer/btc-rpc-explorer node ./bin/www

btcexp:app Searching for config files... +0ms btcexp:app Config file not found at /home/btcrpcexplorer/.config/btc-rpc-explorer.env, continuing... +4ms btcexp:app Config file not found at /etc/btc-rpc-explorer/.env, continuing... +0ms btcexp:app Config file found at /home/btcrpcexplorer/btc-rpc-explorer/.env, loading... +0ms Loading RPC cookie file: /data/bitcoin/.cookie btcexp:app Default cacheId '3.3.0' +2s btcexp:app Enabling view caching (performance will be improved but template edits will not be reflected) +57ms btcexp:app Environment(development) - Node: v14.18.2, Platform: linux, Versions: {"node":"14.18.2","v8":"8.4.371.23-node.85","uv":"1.42.0","zlib":"1.2.11","brotli":"1.0.9","ares":"1.18.1","modules":"83","nghttp2":"1.42.0","napi":"8","llhttp":"2.1.4","openssl":"1.1.1l","cldr":"39.0","icu":"69.1","tz":"2021a","unicode":"13.0"} +18ms btcexp:app Using sourcecode version as cacheId: '581ad524cd' +39ms btcexp:app Starting BTC RPC Explorer, v3.3.0 (commit: '581ad524cd', date: 2021-12-12) at http://127.0.0.1:3002/ +1ms btcexp:app Connecting to RPC node at newRaspberry.local:8332 +1ms btcexp:app Verifying RPC connection... +16ms btcexp:app Loading mining pools config +10ms btcexp:error Error RpcError-001: Error: connect ECONNREFUSED 192.168.1.17:8332, json: {"errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"192.168.1.17","port":8332,"userData":{"request":"getnetworkinfo"}}, userData: [object Object] (json: {"request":"getnetworkinfo"}) +0ms btcexp:errorVerbose Stack: Error: connect ECONNREFUSED 192.168.1.17:8332 btcexp:errorVerbose at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) +0ms btcexp:error Error 32ugegdfsde: Error: connect ECONNREFUSED 192.168.1.17:8332, json: {"errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"192.168.1.17","port":8332,"userData":{"request":"getnetworkinfo"}}, userData: [object Object] (json: {}) +3ms btcexp:errorVerbose Stack: Error: connect ECONNREFUSED 192.168.1.17:8332 btcexp:errorVerbose at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) +2ms btcexp:error Error 937gf47dsyde: Error: connect ECONNREFUSED 192.168.1.17:50001, json: {"errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"192.168.1.17","port":50001}, userData: [object Object] (json: {"host":"newraspberry.local","port":50001,"protocol":"tcp"}) +3ms btcexp:errorVerbose Stack: Error: connect ECONNREFUSED 192.168.1.17:50001 btcexp:errorVerbose at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) +4ms btcexp:error Error 120387rygxx231gwe40: Error: connect ECONNREFUSED 192.168.1.17:50001, json: {"errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"192.168.1.17","port":50001}, userData: [object Object] (json: {}) +2ms btcexp:errorVerbose Stack: Error: connect ECONNREFUSED 192.168.1.17:50001

etc.

Additional context

I have read all issues that seemed related and searched online.

ahuw commented 2 years ago

Sorry I read up on this and initialblockdownload:false means the opposite of what I had assumed

Is it related to the blockchain not being fully downloaded?

~ $ bitcoin-cli getblockchaininfo { "chain": "main", "blocks": 716420, "headers": 716420, "bestblockhash": "0000000000000000000645d7670d06cdd500fb82ccc8f2bea9b2e5d61720983f", "difficulty": 24272331996979.97, "mediantime": 1640880822, "verificationprogress": 0.9999972629601385, "initialblockdownload": false, etc.

This shows progress=1.00. Does it dip below 1 at times?: ~ $ sudo tail -f /home/bitcoin/.bitcoin/debug.log 2021-12-30T16:30:00Z Socks5() connect to 176.230.52.18:8333 failed: TTL expired 2021-12-30T16:38:33Z Socks5() connect to 5.135.143.84:8333 failed: general failure 2021-12-30T16:41:30Z Socks5() connect to 170.247.241.246:8333 failed: connection refused 2021-12-30T16:45:51Z UpdateTip: new best=0000000000000000000349f6e9b56b2f142614f29644597e979beb024d9eb017 height=716418 version=0x24de6004 log2_work=93.258167 tx=699020999 date='2021-12-30T16:45:31Z' progress=1.000000 cache=115.3MiB(1008582txo) 2021-12-30T16:50:20Z UpdateTip: new best=0000000000000000000b8c878f5998f06893655c0b1af8cae48fed369dc435d4 height=716419 version=0x206ea004 log2_work=93.258179 tx=699022824 date='2021-12-30T16:50:48Z' progress=1.000000 cache=115.7MiB(1011937txo) 2021-12-30T16:54:05Z UpdateTip: new best=0000000000000000000645d7670d06cdd500fb82ccc8f2bea9b2e5d61720983f height=716420 version=0x20000004 log2_work=93.258192 tx=699024154 date='2021-12-30T16:54:17Z' progress=1.000000 cache=115.4MiB(1009924txo) 2021-12-30T16:58:58Z Socks5() connect to 94.213.43.77:8333 failed: connection refused 2021-12-30T16:59:30Z Socks5() connect to 104.244.77.122:8333 failed: general failure 2021-12-30T17:07:46Z Socks5() connect to 108.56.140.144:8333 failed: general failure 2021-12-30T17:10:17Z UpdateTip: new best=00000000000000000009c35364aae4444cdc52d84c2e97bb7da7d4ddc5083f98 height=716421 version=0x2fffe004 log2_work=93.258205 tx=699027370 date='2021-12-30T17:09:21Z' progress=1.000000 cache=116.5MiB(1020087txo)

ahuw commented 2 years ago

I think it's a permissions problem.

I tried to update

btcrpcexplorer@newRaspberry:~/btc-rpc-explorer $ npm install -g npm

and got

npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/abbrev etc.

The permissions are rwxr-xr-x and owner and group are root

btcrpcexplorer is in groups btcrpcexplorer and bitcoin

If I try to use bitcoin-cli as btcrpcexplorer I get

btcrpcexplorer@newRaspberry:~ $ bitcoin-cli getblockchaininfo error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (/home/btcrpcexplorer/.bitcoin/bitcoin.conf)

But then doesn't this show that bitcoin group members can use bitcoin-cli?

btcrpcexplorer@newRaspberry:~ $ ls -la /home/bitcoin/.bitcoin/.cookie -rw-r----- 1 bitcoin bitcoin 75 Dec 29 20:53 /home/bitcoin/.bitcoin/.cookie

ahuw commented 2 years ago

I changed BTCEXP_BITCOIND_HOST=newRaspberry.local to BTCEXP_BITCOIND_HOST=127.0.01 as it should have been and it seems to work now

I had also installed the wrong OS so please forgive my incompetence