title: Postgres "Connection timed out" when connecting from debian and ubuntu clients, but fine from Windows
body: <p><strong>Update</strong>:</p>
  <p>This seems to be related to just how Docker changes the iptables and leaves its settings even after disabling its iptables rule setting capabilities. Issue can be resolved by modifying <code>/etc/docker/daemon.json</code> and setting <code>{ &quot;iptables&quot;: true }</code></p>
  <p>I just did a fresh install of Debian 11. Installed postgres without docker, and was able to connect to my server. I just installed docker and tried to connect from a postgres container and was not able to reach server. This issue seems to be related to firewalling around docker.</p>
  <p>I am running postgres 13.4 on a debian server through docker, hosted on DigitalOcean. I've setup a very open config just to see if I can connect to my server from various clients that are not local. Here is how I've configured my <code>pg_hba.conf</code> file:</p>
  <pre><code># TYPE  DATABASE        USER            ADDRESS                 METHOD
  
  # &quot;local&quot; is for Unix domain socket connections only
  local   all             all                                     trust
  # IPv4 local connections:
  host    all             all             0.0.0.0/0            md5
  # 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
  </code></pre>
  <p><code>postgresql.conf</code>:</p>
  <pre><code>#------------------------------------------------------------------------------
  # CONNECTIONS AND AUTHENTICATION
  #------------------------------------------------------------------------------
  
  # - Connection Settings -
  
  listen_addresses = '*'
  </code></pre>
  <p>My way to connect from client side is to use a postgres docker container so that I can use the <code>psql</code> command without installing postgres on that client. I've tried 3 different client machines.</p>
  <p>Windows 10 from home network works fine:</p>
  <pre><code>root@7eb2296a9cf6:/# psql -h 111.222.143.193 -p 5432 -U postgres
  Password for user postgres:
  </code></pre>
  <p>Debian 10 from home network fails:</p>
  <pre><code>root@38161cc233c1:/# psql -h 111.222.143.193 -p 5432 -U postgres
  psql: error: could not connect to server: Connection timed out
          Is the server running on host &quot;111.222.143.193&quot; and accepting
          TCP/IP connections on port 5432?
  </code></pre>
  <p>Ubuntu 20.04 from Linode network fails:</p>
  <pre><code>root@3706fd7cbdd4:/# psql -h 111.222.143.193 -p 5432 -U postgres
  psql: error: could not connect to server: Connection timed out
          Is the server running on host &quot;111.222.143.193&quot; and accepting
          TCP/IP connections on port 5432?
  </code></pre>
  <p>Here is the UFW status (I've changed the IP for privacy)</p>
  <pre><code>Status: active
  
  To                         Action      From
  --                         ------      ----
  787/tcp                    ALLOW       Anywhere
  Anywhere                   ALLOW       93.551.148.352
  80/tcp                     ALLOW       Anywhere
  443/tcp                    ALLOW       Anywhere
  5432                       ALLOW       Anywhere
  787/tcp (v6)               ALLOW       Anywhere (v6)
  80/tcp (v6)                ALLOW       Anywhere (v6)
  443/tcp (v6)               ALLOW       Anywhere (v6)
  5432 (v6)                  ALLOW       Anywhere (v6)
  </code></pre>