nxdomain for Elixir app

Hello,

I’m trying to deploy this Elixir app GitHub - mirego/accent: The first developer-oriented translation tool. True asynchronous flow between translators and your team..

It should be pretty easy because I already had it running on Heroku with Dockerfile what they have in that repo. But it doesn’t work with Fly.

Issue is with connecting with postgresql, I tried it yesterday and today. I attached postgresql with fly cli and I see secret in application.

failed to connect: ** (DBConnection.ConnectionError) tcp connect (top2.nearest.of.cookienovo-db.internal:5432): non-existing domain - :nxdomain

Dockerfile is same as it is in repo, I just added this at the bottom, also tried without it.

# Appended by flyctl
ENV ECTO_IPV6 true
ENV ERL_AFLAGS "-proto_dist inet6_tcp"

Toml is just generated one with these envs:

DATABASE_POOL_SIZE = 5
PORT = "8080"

I’m not able to connect to that app with fly ssh console too, it’s just connecting. Fly doctor looks ok, I’m able to connect and play with other apps without any problems.

fly ssh console
Connecting to top1.nearest.of.cookienovo-accent.internal... complete
Error error connecting to SSH server: connect tcp [fdaa:0:7c41:a7b:a992:66dd:5ad1:2]:22: operation timed out

Ecto needs to be told about ipv6 in your config/runtime.exs, which newer generated phoenix projects sets for you. In your config/runtime.exs, replace your repo config with the following:

ecto_ipv6? = System.get_env("ECTO_IPV6") == "true"

config :accent, Accent.Repo,
  pool_size: Utilities.string_to_integer(System.get_env("DATABASE_POOL_SIZE")),
  ssl: Utilities.string_to_boolean(System.get_env("DATABASE_SSL")),
  url: System.get_env("DATABASE_URL") || "postgres://localhost/accent_development",
  socket_options: if(ecto_ipv6?, do: [:inet6], else: [])  

Thanks. It helped. I made PR with your code in repo too. Thank you.

I’m using Phoenix 1.8.1 and still running into the connection issue ( using managed postgres). I have had an active Fly support issue for past 2 days and have been unable to resolve.

2025-11-23T07:51:06Z app[XXXXXXXXX] sjc [info]07:51:06.484 [error] Postgrex.Protocol (#PID<0.4540.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (``pgbouncer.XXXXXXXX.flympg.net:5432``): non-existing domain - :nxdomain

also unable to connect to the pgbouncer or direct url when ssh’d into the machine:

flyctl ssh console –app XXXXXX Connecting to XXXXX complete root@XXXXXX:/app# nslookup direct.XXXXXXXX.flympg.net Server: fdaa::3 Address: fdaa::3#53

** server can’t find direct.XXXXXXXX.flympg.net: NXDOMAIN

I did add your recommended update to the runtime.exs since my project was generated before this pattern was added to generators, so it used to have the hardcoded socket_options: [:inet6].

after re-deploy / restart I still see the :nxdomain log errors when the app tries to connect

excerpt from my runtime.exs

# Check if IPv6 is enabled for Ecto (conditional pattern from newer Phoenix generators)

ecto_ipv6? = System.get_env("ECTO_IPV6") == "true"

# Auto-detect Managed Postgres (has .flympg.net in URL) for automatic SSL/PgBouncer config

is_managed_postgres = String.contains?(database_url, ".flympg.net")

repo_config = [
 url: database_url,
 socket_options: if(ecto_ipv6?, do: [:inet6], else: []),
 pool_size: pool_size,
 timeout: 15_000,
 queue_target: queue_target,
 queue_interval: queue_interval