Connecting to postgres running in a container from outside

Hello all,

I have an lxd based container on which i have installed postgres, I can access postgres using psql from the host system.

But how can I access postgres from outside host system, say for example from any other system using pgadmin.

I’m using some example IP address for references
x.x.x.x.x is my external host ip address
192.168.0.20 is my postgres container and 5432 is my postgres port

Thank you so much in advance

Take a look at the proxy instance device for forwarding a port on the host (reachable from other machines on the host’s external network) to the instance:

2 Likes

Thank you so much @tomp I was able to do with the below command

sudo lxc config device add postgres port5432tcp proxy listen=tcp:0.0.0.0:5432 connect=tcp:192.168.0.20:5432

2 Likes