Search code examples
postgresqlcookiecutter-django

How do I connect to the postgres from my home OS using a GUI client like postico?


I am running the Django Cookiecutter on Docker and tried to connect to the postgres database using Postico, a GUI client on my laptop.

The credentials I used was basically the same as .envs/.local/.postgres Yet I still cannot connect.

I wonder what's the issue that's blocking me from doing so?


Solution

  • The issue is that I wasn't aware that Docker allows you to state which ports get mapped to the host OS.

    See https://docs.docker.com/compose/compose-file/#network_mode for details.

    Specifically, I needed to go to local.yml under postgres definition and add:

    ports:
          - "5432:5432"
    

    Then restart the docker.

    In case you want to map different port number note that the syntax is

    the HOST:CONTAINER format