How to access postgresql located on localhost from container

I want to access postgresql which resides on localhost from within the nodejs application container. How to do that? and what is the best practice to do that in production?

AFAIK you can only access node‘s localhost from within container with special settings in Docker Desktop.

For Production, use all services in container, use dedicated IP of host (not localhost) or create additional private IP (e.g. 10.x.x.x) on host to use.

1 Like

Your container is using host network or bridge network? Please confirm

In case of host network you might be able to access using the local addresses but that is definitely not advisable in production