Failed to connect to database: org.postgresql.util.PSQLException: Connection to localhost:5432 refused (with Docker)

I am trying add an existing postgresql database to metabase. I don’t have a lot of experience with Docker Desktop or metabase.

Both are running on my local machine using Docker Desktop containers.

Here’s my error on Metabase and some of my config on Docker Desktop.


Container logs: Failed to connect to database: org.postgresql.util.PSQLException: Connection to localhost:5432 refused.

Can anyone tell me what i’m missing?

Sounds like you need to configure Docker networking between your Metabase and Postgres containers. Localhost seen from your Metabase container is the Metabase container itself.

An easy way to configure networking between several containers is through a Docker compose file. See: