Host.docker.internal seems doesnt work with CI/CD Github Action LINUX

Hello everyone, im new here and using docker. We are developing an app and we need to use a subgraph, so the community that mantain TheSubgraph shared us a repo to run local node and test our subgraph. This work locally as we want, but we need test this with GitHub actions. Im using WSL2 with Ubunto 20.04LTS and this work nicely, but when we execute the GitHub action seems like a node is not connecting correctly. I did a lot of research, and i really think that host.docker.internal is not resolving the IP in the GH Action. My PC do that because im using WSL and Docker for Windows and automatically know how resolve it (not sure if this is the real issue but im just thinking about it).

I know is something about this connection because the error is "WARN Trying again after net_version RPC call failed (attempt #10) with result Err(Transport error: Error(Connect, Os { code: 111, kind: ConnectionRefused, message: "Connection refused" }))", which appear when i change the host.docker.internal or i added a extra_host inside the docker-compose. Im not really sure about why this not run inside GitHub action and tbh i read a lot this days trying but wihtout success. So i decide to ask in the forum. This is no my area, but i need to run the test with this node and the tool is perfect to test.

I’ll share the docker-compose.yml file and the repo that the community shared us and we are using:
This is the repo, and this is the docker folder

version: '3'



    image: graphprotocol/graph-node:v0.22.0


      - '8000:8000'

      - '8001:8001'

      - '8020:8020'

      - '8030:8030'

      - '8040:8040'


      - ipfs

      - postgres


      postgres_host: postgres

      postgres_user: graph-node

      postgres_pass: let-me-in

      postgres_db: graph-node

      ipfs: 'ipfs:5001'

      ethereum: 'localhost:http://host.docker.internal:8545'

      GRAPH_LOG: info


    image: ipfs/go-ipfs:v0.4.23


      - '5001:5001'


      - ./data/ipfs:/data/ipfs


    image: postgres


      - '5432:5432'

    command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]


      POSTGRES_USER: graph-node

      POSTGRES_PASSWORD: let-me-in

      POSTGRES_DB: graph-node


      - ./data/postgres:/var/lib/postgresql/data

I hope that im asking in the right place and get some help. I tried to run this with CI/CD in Github since like a week. Let me know if is necessary more info or something, i really thanks for any help :slight_smile:

host.docker.internal which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.

You could use something like host-gateway: How to reach localhost on host from docker container? - #5 by meyay

  • or run everything in containers, connect to the same docker network and use the service names.
  • Or use the host network in the containers.
  • or use static IP address if you know the host IP.

There are multiple potential solutions. It depends on the actual usecase

1 Like

Hello rimelek, thanks for the info. Im very new in Docker. It is my first contact with this, i really appreciate the help. I tried using the extra_host ( "host.docker.internal:"), but doesnt work even locally. Should be that i using a wrong ip.

  • “run everything in containers, connect to the same docker network and use the service names.” - I do not know how make this, but i’ll search it and see.

  • “There are multiple potential solutions. It depends on the actual usecase” - Well, we need run the services locally because we are writing the tests, and make sure that is running in GH actions.

Actually, i’ll search everything because i’m not 100% sure what or how do it. I’ll ask again surely, thanks:),

You don’t need IP address. Use “host-gateway” instead. It will be replaced with the proper IP address dynamically.

Hello, im having the same error with my setup. Even though I already set the extra hosts correctly.
Although this setup is working locally.
BTW im using docker-compose

      - "host.docker.internal:host-gateway"

The environment files connecting to my app are still using host.docker.internal though, is that how it should be?


this is the docker-compose build error i’m getting on the runner

If you still have this problem after 9 days: It should work, however I don’t know if Django uses the hosts file or not. If it tries to use a DNS server, it won’t work, because extra hosts are inserted into the hosts file. Bash commands like curl and wget would probably work, but if you try nslookup, that would not recognize the domain either. It could be the same with django.