Cannot connect to localhost PgAdmin 4 server

Hi,

I have just downloaded Metabase and it looks like a great tool. However, I am having issues connecting it to a local postgresql server running through PgAdmin 4.

I have got metabase running only my localhost using port 3000, inside a docker container:

Here is what my SQL database settings look like:

However, every time I try and connect, I get this issue:

Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Can someone please explain to me what I am doing wrong? I am completely new to Metabase so step by step explanations would be super appreciated.

Thank you!

Hi @zigzagdoom
If you’re running Metabase in Docker, then localhost is the container itself.
If you need to connect from the container to the host, then have a look here:
https://stackoverflow.com/questions/28056522/access-host-database-from-a-docker-container

2 Likes

Thank you @flamber!

@flamber - I am having this same problem and don't understand the solution you've provided. I am running Metabase in Docker.

Note: Both Docker and my Postgres sql database (through DBeaver) are running locally on my Windows machine.

Note 2: I am totally new to this and feel a bit underwater with it all. THANK YOU

Would I run the following command then?

docker run --add-host=docker:10.180.0.1 --rm -it metabase/metabase

@rkacton It sounds like a totally different problem from this topic, which is about PgAdmin.

I would recommend that you use JAR if you're not familiar with Docker:
https://www.metabase.com/learn/getting-started/getting-started/installing.html

If you want to use Docker, but not sure how Docker works, then I would recommend looking for help on stackoverflow.com (or another Docker forum) since your problem is not specific to Metabase.

1 Like

Hi @rkacton, when you are running metabase using docker and your database is in localhost, you can try using your current IP in the server name. You can get your localhost IP executing ipconfig in the cmd.

Use this :
host.docker.internal

Instead of this:
localhost

Problem solved in a moment!