Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana

Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64)

If you follow the defaults for docker-compose then the postgres database will not allow you to connect to it with a connection refused error.

Sample error message from the logs:
grafana_1 | t=2021-10-31T20:39:21+0000 lvl=eror msg=“query error” logger=tsdb.postgres err=“dial tcp 127.0.0.1:5432: connect: connection refused”

Thanks for the feedback…unfortunately, I am unable to replicate the issue. Are you sure that you configured the Postgres data source properly in Grafana? Perhaps the credentials are invalid?

The only way I found to make it work was to change from “localhost” to my host ip address. Everything else stayed the same.

If you are running postgres and grafana via docker compose you should be able to use the postgres container hostname when setting up the data source in grafana. If that doesn’t work I would suspect something is off with the networking between the containers.

Figured out what the problem was. I was putting in “localhost” and not “postgres”. That was the problem.