Grafana crashes when trying to connect to postgres: panic: setting PGSERVICEFILE not supported

I don’t know enough about your setup to really comment on the source of the issue, but I did a quick experiment locally and can reproduce what you’re seeing, with the root cause I mentioned; namely:

  • If I set an environment variable PGSERVICEFILE=abcd (i.e. give it some random value), when I run Grafana and try to add a Postgres data source I get the same error
  • If I do not set this environment variable, everything works great

So you basically need to work out why that variable is set in Grafana’s environment. Note that this is not related to the environment that Postgres is running in, it’s the environment that the Grafana process is running in. And to your last question, no, it’s not Grafana itself that’s setting that environment variable, it’s something else on your system.

1 Like