title: How do I connect to host.docker.internal postgres instance?
body: <p>I'm trying to connect to my local server.  I have the following docker-compose.yaml and servers.json files.  I think I'm making a mistake with my .pgpass.  When the containers are up and running I can login to pgAdmin, and I can see the docker_postgres_group &quot;group&quot;, but when I try to login I get the authentication error in the first screenshot below.  Further below is how I've got my pgpass set up.  I think this is where the problem is, but I could be wrong...</p>
  <p><strong>docker-compose.yaml</strong></p>
  <pre><code>version: '3.8'
  services:
    db:
      container_name: pg_container
      image: postgres
      restart: always
      environment:
        POSTGRES_USER: root
        POSTGRES_PASSWORD: root
        POSTGRES_DB: test_db
      ports:
        - &quot;5432:5432&quot;
    pgadmin:
      container_name: pgadmin4_container
      image: dpage/pgadmin4
      restart: always
      environment:
        PGADMIN_DEFAULT_EMAIL: admin@admin.com
        PGADMIN_DEFAULT_PASSWORD: root
     
      ports:
        - &quot;5050:80&quot;
      volumes:
         - ./servers.json:/pgadmin4/servers.json # preconfigured servers/connections
         - ./pgpass:/pgpass # passwords for the connections in this file
  </code></pre>
  <p><strong>servers.json</strong></p>
  <pre><code>{
    &quot;Servers&quot;: {
      &quot;1&quot;: {
        &quot;Name&quot;: &quot;docker_postgres&quot;,
        &quot;Group&quot;: &quot;docker_postgres_group&quot;,
        &quot;Host&quot;: &quot;host.docker.internal&quot;,
        &quot;Port&quot;: 15432,
        &quot;MaintenanceDB&quot;: &quot;postgres&quot;,
        &quot;Username&quot;: &quot;postgres&quot;,
        &quot;PassFile&quot;: &quot;/pgpass&quot;,
        &quot;SSLMode&quot;: &quot;prefer&quot;
      }
    }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/LErba.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LErba.png" alt="pgadmin screenshot" /></a></p>
  <p><strong>.pgpass</strong>
  This is what's inside my pgpass file:  host.docker.internal:15432:postgres:postgres:postgres</p>
  <p>Here's its location:
  <a href="https://i.stack.imgur.com/jCcXK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jCcXK.png" alt="enter image description here" /></a></p>
  <p>I've tried having the .pgpass file in the pgpass folder and outside.<br />
  And - I'm using postgres as the password to try to login to pgadmin.</p>