Connecting to postgresql-11.5.1 from grafana is not working. I installed postgres on my local and created a grafana and trying to connect, but i get the usual error: dial tcp 127.0.0.1:5432: connect: connection refused am NOT using postgresql on docker, its just on my local on windows 10. because the answers that is available on stackoverflow is related to docker. Please help..
In my case, I deployed Grafana locally with Docker and was attempting to use the Postgres plugin to connect to my local installation of Postgres. I had to use host.docker.internal
as the host instead of localhost
which was causing the same error:
Please do check these configuration files for Postgresql.
/etc/postgresql//main/postgresql.conf
/etc/postgresql//main/pb_hba.conf
Client authentication is maintained by making changes to pb_hba.conf
. Make sure it has this line for local authentication.
[TYPE] [DATABASE] [USER] [ADDRESS] [METHOD]
host all all 127.0.0.1/32 md5
The Grafana instance now lives in a different network and Postgres will have a remote connection with it. By default, the local connection is available only. To enable remote,
sudo vim /etc/postgresql//main/postgresql.conf
Change #listen_addresses = 'localhost'
to #listen_addresses = '*'
.
Obtain docker bridge network interface info in your terminal by typing.
ip addr
........
docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group
default
link/ether 02:42:da:5e:5e:95 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:daff:fe5e:5e95/64 scope link
valid_lft forever preferred_lft forever
Here inet 172.17.0.1/16 refers to
Allow this network 172.17.0.0/16
from your machine in pb_hba.conf
.
host all all 172.17.0.0/16 md5
Now, use the ip address (172.17.0.1) obtained from ip addr
from your machine in place of localhost as Grafana data source address.
Reference
Allow docker container to connect to a local/host postgres database
https://blog.jsinh.in/how-to-enable-remote-access-to-postgresql-database-server/#.XXYs2HUvNuS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With