title: PostgreSQL Docker connection error - "no encryption"
body: <p>I'm trying to run a PostgreSQL database on a Docker container while allowing outside connections to it. I am using the &quot;official&quot; PostgreSQL Docker image (version 13).
  After running the image, exposing its 5432 port, and mapping the container's 5432 port to the host's 5432 port I am greeted with the following error when trying to connect to it:</p>
  <p><code>Fatal error: np pg_hba.conf entry for host &quot;my_ip&quot;, user &quot;admin&quot;, database &quot;postgres&quot;, no encryption.</code></p>
  <p>I've looked everywhere for a solution but all the answers are the same, so I will write here what has been suggested and I already did (or existed already):</p>
  <ol>
  <li>The line: <code>listen_addresses = '*'</code> is in the file <code>postgresql.conf</code>.</li>
  <li>The line <code>host all all 0.0.0.0/0 md5</code> is in the file <code>pg_hba.conf</code>.</li>
  <li>Ran the image with <code>--expose 5432</code> and <code>-p 5432:5432</code>.</li>
  </ol>
  <p>I've also tried adding the lines: <code>host all all ::1/128 md5</code> &amp;&amp; <code>host all postgres 127.0.0.1/32 md5</code> in <code>pg_hba.conf</code> (with AND without <code>host all all 0.0.0.0/0 md5</code>).</p>
  <p>I'm at a loss of what to do or try next - can anyone please suggest something to solve this pickle?</p>
  <p>Thanks in advance!</p>