Accessing to the database from outside the container

How can i access to the database from ouside the container but in the same server (local)

I open the port in app.yml

expose:
  - "4002:5432" #postgres

Try to connect from outside with

psql -h 127.17.0.1 -p 4002 -d postgres -U postgres -p ''
psql: could not connect to server: Connection refused
        Is the server running on host "127.17.0.1" and accepting
        TCP/IP connections on port 5432?

What i’m missing ?