title: Unable to connect to host from docker container
body: <p>I am having trouble accessing my host machine from a docker container, getting Connection refused error. I tried to solve it following this SO question: <a href="https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach">From inside of a Docker container, how do I connect to the localhost of the machine?</a></p>
  <p>Docker version is <strong>20.10.18, build b40c2f6</strong>
  Host is Ubuntu 22.04 LTS</p>
  <p>What I am doing:</p>
  <ul>
  <li>Started a server on port 3000 on the host machine</li>
  <li>server is accessible with <code>curl localhost:3000</code></li>
  </ul>
  <p>Then I tried the following, using curl docker image for testing, all throwing Connection refused error</p>
  <pre class="lang-bash prettyprint-override"><code># using host.docker.internal
  docker run --add-host host.docker.internal:host-gateway --rm curlimages/curl:7.85.0 host.docker.internal:3000
  # using IP from docker0 network 172.17.0.1
  docker run --rm curlimages/curl:7.85.0 172.17.0.1:3000
  # using host network
  docker run --network=host --rm curlimages/curl:7.85.0 localhost:3000
  </code></pre>
  <p>What am I missing?</p>