Unable to connect app to postgres

Hello, hit my next issue. Try to deploy a pretty barebones phoenix app, but am unable to connect to my postgres instance. Here is what appears in the logs:

2022-09-26T22:00:48Z app[1f87fde3] ord [info]22:00:48.518 [error] Postgrex.Protocol (#PID<0.137.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (top2.nearest.of.livestate-platform-db.internal:5432): non-existing domain - :nxdomain

I am able to connect via flyctl pg connect -a livestate-platform-db tho my first try gave me an ssh error. Subsequent attempts brought up the psql prompt as expected. I’ve also try to detach and attach. No luck so far.


Just checked postgres logs, I see:

2022-09-26T21:40:33.279 app[c8d4b759] ord [info] exporter | INFO[0051] Established new database connection to "fdaa:0:a774:a7b:8c31:2:ea9:2:5433". source="postgres_exporter.go:970"

2022-09-26T21:40:33.287 app[c8d4b759] ord [info] exporter | INFO[0051] Semantic Version Changed on "fdaa:0:a774:a7b:8c31:2:ea9:2:5433": 0.0.0 -> 14.4.0 source="postgres_exporter.go:1539"

2022-09-26T21:50:13.665 app[c8d4b759] ord [info] 2022/09/26 21:50:13 unexpected error: transient SSH server error: can't resolve _orgcert.internal

2022-09-26T21:50:13.703 app[c8d4b759] ord [info] 2022/09/26 21:50:13 unexpected error: [ssh: no auth passed yet, transient SSH server error: can't resolve _orgcert.internal]

Seems like this must be causing the issue


After a restart, this postgres logs now look normal but I am still unable to connect from the app.

I was able to figure this out, it appears the default phoenix app config for needed to be changed to allow ipv6 connections:

  config :live_state_platform, LiveStatePlatform.Repo,
    # ssl: true,
    socket_options: [:inet6],
    url: database_url,
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

The socket_options line was commented out initially by the phoenix generator at least at the version I had.