Unable to connect to server: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
docker inspect
-f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
<container_name_or_id>
# Outputs is the IP address you need to connect to