Okay, so you already publish a port.
If intelliJ is inside the vm, you need to use
localhost:5432 to access the postgres database.
If intelliJ is running on the host, it pretty much depends if your VM uses the NAT or Host-only network.
If the network uses the Host-only network, you need to use
ip of the vm:5432 to connect to postgres.
If the network uses NAT network, you need to start “Virtual Network Editor” as admin, select on the NAT network, click on “NAT Settings…” button, click “add” to add your port forwarding. Then you need to use
localhost:5432 (or whatever host port you defined) to connect to postgres.
If you need help with NAT portforwarding, I would suggest to raise a topic in a vmware forum.