title: Docker PostgreSQL: cannot connect to the server on Windows 7
body: <p>I run on Windows 10</p>
  
  <pre><code>docker run -it --rm -e POSTGRES_PASSWORD=postgres -p5401:5432 postgres:12.3-alpine
  </code></pre>
  
  <p>it works fine. I can connect to PostgreSQL, create database etc, all is ok.</p>
  
  <p>But when I run the same docker on my 2nd machine Windows 7 I receive</p>
  
  <blockquote>
    <p>Could not connect to server: Connection refused (0x0000274D/10061) Is
    the server running on host "localhost" (::1) and accepting TCP/IP
    connections on port 5401?</p>
  </blockquote>
  
  <p>What may be the reason? what to check?</p>
  
  <h2>That is pg_hba.conf</h2>
  
  <pre><code># TYPE DATABASE USER ADDRESS METHOD
  
  # "local" is for Unix domain socket connections only
  local all all trust
  # IPv4 local connections:
  host all all 127.0.0.1/32 trust
  # IPv6 local connections:
  host all all ::1/128 trust
  # Allow replication connections from localhost, by a user with the
  # replication privilege.
  local replication all trust
  host replication all 127.0.0.1/32 trust
  host replication all ::1/128 trust
  host all all all md5
  </code></pre>