janoside / btc-rpc-explorer

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

ECONNREFUSED with Docker on Win10 With bitcoin core V 0.21. #326

Open HasseM opened 3 years ago

HasseM commented 3 years ago

No matter what I try, I keep getting ECONNREFUSED.

image

I'm running this on Docker for windows and I am using Bitcoin QT on my win10 host. I have edited bitcoin.conf and set a rpcuser and password and also set server=1. I also edited .dev to match the usernamen/password. I also tried starting bitcoinqt with commandline options but that did not make a difference.

I can open the webserver but I get this: image

I'm not very experienced with docker. So I am wondering if this is the docker container blocking the connection or if it is bitcoin qt that does not accept it. Maybe there is a more fundamental problem? Any advise would be greatly appreciated!

Edit: I seem to be able to access btcoin qt from python (both on host, not in docker). So bitcoin qt is running fine, no problem there. So, it seems that rpc explorer is either not able to reach bitcoin qt outside of the docker, or is using wrong credentials.

Edit2: Really cannot fix this.... tried every thing I could think off. must be a bug.

janoside commented 3 years ago

@HasseM To be frank, I'm not very experienced with Docker myself...sorry about that! But, I'm working on getting more experience in this area and I made some recent changes to update the docker image (it looks like you have them, so that's good).

My best guess at the moment for this issue is that your config file isn't getting loaded as you expect. But, since I might be wrong, we can try to test this theory and learn together...

If you navigate to /admin/dashboard you should see a section named "App Config" that has settings that can be modified with your .env file. To test my theory, see if any of the settings listed there do NOT match corresponding values in your .env file that has your environment variables. Any mismatch would suggest that the .env file is NOT being loaded. Be sure that you take the default values (listed in the .env-sample file) into account when making this assessment. If you need to add/change an environment variable to test this theory please do so and then re-start the container to make sure the change is loaded (which only happens at startup).

Let me know what you find and we can keep working through this.

HasseM commented 3 years ago

@janoside I am not really sure where I should navigate to /admin/dashboard. I tried it in my browser: http://localhost:3002/admin/dashboard but I do not see something with App Config there. So obviously, you mean something else?

Meanwhile I was trying to test my bitcoin core V0.21 RPC connection from python:

import asyncio from bitcoinrpc import BitcoinRPC

async def main(): async with BitcoinRPC("localhost", 8332, "myuser", "mypass") as rpc: print(await rpc.getconnectioncount()) # is okay

print(await rpc.getnetworkinfo()) # error

    #print(await rpc.getblockchaininfo()) # error

if name == "main": asyncio.run(main())

The strange thing is that getconnectioncount() is working but as soon as I try things like getblockchaininfo(), I get an exception error from python. (does it need a parameter?) So personally I am still not sure where to look for the root cause of the problem.

I'm also pretty sure it loads my .env file. I tried changing IP and port and these changes show up in the log.

edit: I now do think that the admin dashboard is part of the web gui. but no App Config there. I can go to /user-settings, but still not the information you would like to see: image

HasseM commented 3 years ago

I have a major update on the above. It seems that when I use rpcauth in my bitcoin.conf that I can make rpc connections via Python now. This was not working either. I managed to call getnetworkinfo and getblockchainfino with correct results. But, this is from python. It is still failing to do so from btc-rpc-explorer. But I am getting more convinced that this has to do with my bitcoin.conf in combination with a docker container.

How should I set rpcallow and rpcbind when I try to connect from docker (Win10 host)? I now have: rpcallowip=0.0.0.0/0 rpcbind=127.0.0.1

or maybe the other way around: What should I put in .env file to reach the host from a docker container? (currently I have 127.0.0.1)

Another possible solution may be to use docker volumes to access the .cookie? I probably need some guidance there.... Edit: I managed to copy my current cookie file to the container and change .env to use the cookie. It uses the cooookie according the log, but I got exactly the same result....

blackdimund commented 2 years ago

mine ended up just having the webui have 3 copies of the empty explorer and no rpc connection 3 times on the same page, and its the same page on settings and /admin/dashboard, ill try installing without docker.

EDIT: turns out i could not get bitcoind docker connected to RPC

suchdatums commented 2 years ago

I am getting the same error while running this in docker. When I run this project with 'npm start' it works and uses my .env to connect to my node. But when I build the docker image and run I'm getting the same error as described above. Using MacOS with Bitcoin Core v23.0.0