Samourai-Wallet / samourai-dojo

End-to-end bitcoin wallet backing server for powering Samourai Wallet and other light wallets
https://samouraiwallet.com/dojo
Other
168 stars 78 forks source link

ECONNREFUSED from external bitcoind #168

Open Dwyte opened 3 years ago

Dwyte commented 3 years ago

Describe the issue ECONNREFUSED from external bitcoind. I've tried everything I could form the instructions, I never used docker before so I might be missing something...

Error log:

explorer    | 2020-08-28T10:26:01.453Z btcexp:app Verifying RPC connection...
explorer    | 2020-08-28T10:26:01.454Z btcexp:error Error 32euofeege: Error: connect ECONNREFUSED 127.0.0.1:8080, json: {"cause":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080},"isOperational":true,"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}, userData: [object Object] (json: {"cmd":"getnetworkinfo"})
explorer    | 2020-08-28T10:26:01.454Z btcexp:error Error 32ugegdfsde: Error: connect ECONNREFUSED 127.0.0.1:8080, json: {"cause":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080},"isOperational":true,"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}
nodejs      | 2020-08-28T10:26:14Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:14Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:14Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:14Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
explorer    | 2020-08-28T10:26:31.458Z btcexp:app Verifying RPC connection...
explorer    | 2020-08-28T10:26:31.462Z btcexp:error Error 32euofeege: Error: connect ECONNREFUSED 127.0.0.1:8080, json: {"cause":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080},"isOperational":true,"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}, userData: [object Object] (json: {"cmd":"getnetworkinfo"})
explorer    | 2020-08-28T10:26:31.463Z btcexp:error Error 32ugegdfsde: Error: connect ECONNREFUSED 127.0.0.1:8080, json: {"cause":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080},"isOperational":true,"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}
nodejs      | 2020-08-28T10:26:34Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:34Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:34Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:34Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:54Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:54Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:54Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
nodejs      | 2020-08-28T10:26:55Z  INFO  Bitcoind RPC : API is still unreachable. New attempt in 20s.
explorer    | 2020-08-28T10:27:01.461Z btcexp:app Verifying RPC connection...
explorer    | 2020-08-28T10:27:01.463Z btcexp:error Error 32euofeege: Error: connect ECONNREFUSED 127.0.0.1:8080, json: {"cause":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080},"isOperational":true,"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}, userData: [object Object] (json: {"cmd":"getnetworkinfo"})
explorer    | 2020-08-28T10:27:01.463Z btcexp:error Error 32ugegdfsde: Error: connect ECONNREFUSED 127.0.0.1:8080, json: {"cause":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080},"isOperational":true,"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}

docker-bitcoind.conf

# Type: alphanumeric
BITCOIND_RPC_USER=user

# Password of user account used for rpc access to bitcoind
# Type: alphanumeric
BITCOIND_RPC_PASSWORD=pass 

# other configs... skipped

# IP address of bitcoind used by Dojo
# Set value to 172.28.1.5 if BITCOIND_INSTALL is set to 'on'
# Type: string
BITCOIND_IP=127.0.0.1

# Port of the RPC API
# Set value to 28256 if BITCOIND_INSTALL is set to 'on'
# Type: integer
BITCOIND_RPC_PORT=8080

# Port exposing ZMQ notifications for raw transactions
# Set value to 9501 if BITCOIND_INSTALL is set to 'on'
# Type: integer
BITCOIND_ZMQ_RAWTXS=3000

# Port exposing ZMQ notifications for block hashes
# Set value to 9502 if BITCOIND_INSTALL is set to 'on'
# Type: integer
BITCOIND_ZMQ_BLK_HASH=4200

bitcoin.conf

txindex=1
listen=1
server=1

# Check that bitcoind accepts connections from 127.0.0.1 (linux)
# or from the IP address of the Docker Virtual Machine (MacOS, Windows)
rpcallowip=127.0.0.1

# Check that a port is defined for the RPC API (or 8332 will be used as default value)
rpcport=8080

# Check that the RPC API listens on an IP address accessible from the nodejs container
rpcbind=127.0.0.1

# Check that the RPC user is set
rpcuser=user

# Check that the RPC password is set
rpcpassword=pass

# Enable publish hash block on an IP address accessible from the nodejs container
zmqpubhashblock=127.0.0.1:4200

# Enable publish raw transaction on an IP address accessible from the nodejs container
zmqpubrawtx=127.0.0.1:3000

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

crypt-chameleon commented 3 years ago

I have a similar issue, where I have gotten the nodejs container to connect, but still cannot do rpc calls with the explorer or bitcoin-cli now. BUT what helped was 1) don't use 127.0.0.1 for your local machines IP, but the IP address you find using the command "ip a" which would likely be something like 192.168.1.X 2) rpcallowip should be the IP address for the docker container which is something like 172.28.1.x

crypt-chameleon commented 3 years ago

Okay finally got everything to connect to my node by using the following settings in the bitcoin.conf rpcallowip=172.28.1.0/255.255.255.0 rpcallowip=172.30.1.0/255.255.255.0 rpcallowip=192.168.1.0/255.255.255.0 rpcport=8332 rpcbind=192.168.1.x (check what your machine's local IP address via the command "ip a")

The subnets of 172.28.1.0 and 172.30.1.0 I got from looking into the docker-compose file for the dojo app and could see these were the internal IP nets that they were given.

If you are doing a bitcoin-cli command outside the app, remember to add the parameter -rpcconnect=192.168.1.x otherwise it will give you a connection error