I am trying to connect Postrgre with following setting:
- localhost:5432
- Database: database_1
- User: postgres
- pwd:
- SSL Mode: disable
and getting following error:
dial tcp 127.0.0.1:5432: connect: connection refused
Can someone please help.
Thanks
I am trying to connect Postrgre with following setting:
Can someone please help.
Thanks
Well, do you have a Postgres server running on localhost and listening on port 5432?
You can verify the connectivity using another Postgres client and go back to trying to connect from Grafana once you’ve confirmed that. Maybe you’ve already taken such other troubleshooting steps, but none were mentioned in your question.
[Solved]
It appears that I had to specify the docker host IP address instead.
ip add
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN > group default
link/ether 02:42:e1:c9:03:b7 brd ff:ff:ff:ff:ff:ff
inet 172.18.0.1/16 brd 172.18.255.255 scope global docker0
I then specified the 172.18.0.1 IP address and all was fine
References:
If your container is running on Windows or MacOS then you should also be able to access the docker host’s network at the domain name host.docker.internal.
Thank you!
Your comment also helped me connecting to db from golang.
const ( // DB connection info
host = “host.docker.internal”
port = 5432
user = “postgres”
password = “postgresPass”
dbname = “postgres”
)
Thanks, Docker IP helped me
same problem, Sir. I do not use docker. Should I really need to use docker to get rid of that error?
No, the problem was caused by the docker install, the solution was how to fix a docker problem.
Tell us more about your setup.
Hello.
Had the same problem on Win10. putting host.docker.internal as host solved my problem.
Followed instruction below:
Same problem here…
has anyone found another solution yet??
thanks!
as @rostislaved said. I was trynig to connect to postgres from golang and this is what solved it.
Thank you @fcnz !
Curious to know if there’s a solution. Brand new install, trying to connect a local Postgresql as data source, getting same error. I’ve tried most things related to pg_hba.conf and postgresql.conf I’ve found online and no dice.
Hi, I am facing a similar issue. The setup is as follows:
Any clue would be great.
I have this issue for so long. After a long I figured it out finally.
The problem is we are connecting database with our local dsn(database) address. But actually the port running on dokcer is in different address.
type in terminal after running the contaier docker container inspect <postgres container name>
Here go to the network section and find the “IP Address”
Copy this IP address and replace the “localhost” with it. It will work.
Thank you so much this really saved me
Hello I’m still a beginner,
I tried what you said with the command docker container inspect <postgres container name>
and I saw that the address of my database container was 172.20.0.2, however when I put it in and hit the “Save & test button”.
Try setting network_mode to host, for both grafana and postgres containers, or make them bridge.