I have a micro-service watchblockchain that makes requests on bitcoin blockchain. When I use both services, everything works just fine. Then I want to put those services in docker containers. watchblockchain cannot communicate with the bitcoin docker. I use docker image: kylemanna/bitcoind/

Here is my bitcoin.conf file:


I can open a console in the bitcoin container and verify that the blocks are downloading and I can make requests on the blockchain ex: bitcoin-cli getblockcount

In watchblockchain, I have this connection config:

var clientBTC = new bitcoin.Client({
    host: 'bitcoin',
    port:  8332,
    user: 'jfjobidon',
    pass: 'Lw.....='

And I mapped bitcoin to in my hosts file

My docker-compose.yml:

version: "3"
    build: ./watchBlockchain
      - redis
      replicas: 1
        condition: on-failure
    image: redis:4.0
    command: redis-server --appendonly yes
      - "6379:6379"
        constraints: [node.role == manager]
    command: redis-server --appendonly yes

When I launch: docker-compose up, I have the following error:

Error: connect ECONNREFUSED

I think it is a network communication problem.

How can I get my watchblockchain service to communication with the bitcoin docker ?

1 Answer 1


the containers hosts file will differ from your hosts hosts file.

see it kind of like a VM.

Also is the wrong address, you might need to configure the actual ip/hostname your host has and where the service is listening on inside the watchblockchain container.

So Problems:

  • Your docker container knows nothing about the host bitcoin. an entry in your docker hosts /etc/hosts won't change that.

  • Maybe your bitcoin service only binds to localhost - this will also keep any docker container from connecting to it. Maybe you can configure it so that it binds to the docker bridge IP. So only all the docker containers are able to connect to it.

  • It would be easier if your bitcoind would also be a docker container and was configured inside the docker-compose.yml. That way you could resolve the host using the container name. But still your bitcoind should be configured to bind on every interface.

Hope this helps ;)

  • I added the bitcoin docker in the docker-compose.yml and it solved my problem. Thanks :-)
    – jfjobidon
    Mar 30, 2018 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.