Answers: <p>It happens that the problem comes from ufw not allowing connections from docker containers on host ports.
  Deactivating it helped for now, since it's only for dev purpose.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-01-25T08:16:57.593Z
Answers: 2021-01-25T08:16:57.593Z
Answers: dievardump
Body: <p>I am running a nodejs app in a docker (v 20.10.2) container on a Ubuntu 20.04 LTS (this is for dev purpose only)</p>
  <p>My docker-compose config</p>
  <pre><code>  test:
      container_name: forge_test
      restart: always
      image: &quot;node:lts&quot;
      volumes:
        - ../src:/home/node/app
      command: &quot;node test.js&quot;
      user: &quot;node&quot;
      working_dir: /home/node/app
      extra_hosts:
        - &quot;host.docker.internal:host-gateway&quot;
  </code></pre>
  <p>In the docker, I can ping <code>host.docker.internal</code> (which does not work without extra_hosts), however I can not reach any services that I have running on any port (the port I am actually trying to reach is 7545 but none work) on the host.</p>
  <p>Searching for a few hours now, no solutions I have found (adding docker0 to iptable, adding docker.host.internal to /etc/hosts) work.</p>
  <p>Am I missing something? Could there be a firewall blocking access somewhere (II have ufw installed but tbh I don't really know how to use it)?</p>
  <p>I can't find any similar issue where <code>host.docker.internal</code> can be pinged but the posrts not accessed</p>
  
Tags: <docker>
Title: Docker container can't reach host services
UserDisplayName: dievardump
ThreadText: # Docker container can't reach host services
  
  (Asked by: username_0 on 2021-01-24)
  
  I am running a nodejs app in a docker (v 20.10.2) container on a Ubuntu 20.04 LTS (this is for dev purpose only)
  
  My docker-compose config
  
  ```
    test:
      container_name: forge_test
      restart: always
      image: "node:lts"
      volumes:
        - ../src:/home/node/app
      command: "node test.js"
      user: "node"
      working_dir: /home/node/app
      extra_hosts:
        - "host.docker.internal:host-gateway"
  
  ```
  
  In the docker, I can ping `host.docker.internal` (which does not work without extra\_hosts), however I can not reach any services that I have running on any port (the port I am actually trying to reach is 7545 but none work) on the host.
  
  Searching for a few hours now, no solutions I have found (adding docker0 to iptable, adding docker.host.internal to /etc/hosts) work.
  
  Am I missing something? Could there be a firewall blocking access somewhere (II have ufw installed but tbh I don't really know how to use it)?
  
  I can't find any similar issue where `host.docker.internal` can be pinged but the posrts not accessed
  
  **Tags:** docker
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-01-25. Score: 1 | Accepted answer
  
  It happens that the problem comes from ufw not allowing connections from docker containers on host ports.
  Deactivating it helped for now, since it's only for dev purpose.
  
  
  ---
  
  