fly launch: database has non-existing domain - :nxdomain

Hi I’m taking an existing phoenix app that works on digitalocean.

I configured it for three HA databases and fly launch appears to boot and configure them correctly:

Setting secrets on app markably-app-com-db...
Provisioning 1 of 3 machines with image flyio/postgres-flex:15.6@sha256:92917e5770cef6666dddbf17061c2f95b9e19b8155be9a8ce8c35e09e5381167
Waiting for machine to start...
Machine e2867529c996e8 is created
Provisioning 2 of 3 machines with image flyio/postgres-flex:15.6@sha256:92917e5770cef6666dddbf17061c2f95b9e19b8155be9a8ce8c35e09e5381167
Waiting for machine to start...
Machine 90801ed0a13168 is created
Provisioning 3 of 3 machines with image flyio/postgres-flex:15.6@sha256:92917e5770cef6666dddbf17061c2f95b9e19b8155be9a8ce8c35e09e5381167
Waiting for machine to start...
Machine 6e825d07b33078 is created
==> Monitoring health checks
  Waiting for e2867529c996e8 to become healthy (started, 3/3)
  Waiting for 90801ed0a13168 to become healthy (started, 3/3)
  Waiting for 6e825d07b33078 to become healthy (started, 3/3)

Postgres cluster markably-app-com-db created
  Username:    postgres
  Password:    asdf
  Hostname:    markably-app-com-db.internal
  Flycast:     fdaa:0:3adb:0:1::5
  Proxy port:  5432
  Postgres port:  5433
  Connection string: postgres://postgres:asdf@markably-app-com-db.flycast:5432

after the docker image successfully build and when it comes time to run the release, I get this error:


-------
 ✖ release_command failed
-------
Error release_command failed running on machine 9185e7d4f22718 with exit code 1.
Check its logs: here's the last 100 lines below, or run 'fly logs -i 9185e7d4f22718':
  Pulling container image registry.fly.io/markably-app-com:deployment-01J0MWC03GFYKTEC3PA1MZ9Z8S
  Successfully prepared image registry.fly.io/markably-app-com:deployment-01J0MWC03GFYKTEC3PA1MZ9Z8S (756.391441ms)
  Configuring firecracker
  2024-06-18T05:16:45.366841514 [01J0MWDACPP9HSEVMES2H278HJ:main] Running Firecracker v1.7.0
  [    0.038467] PCI: Fatal: No config space access function found
   INFO Starting init (commit: f7402432)...
   INFO Preparing to run: `/app/bin/migrate` as nobody
   INFO [fly api proxy] listening at /.fly/api
  2024/06/18 05:16:45 INFO SSH listening listen_address=[fdaa:0:3adb:a7b:2c9:1953:67e5:2]:22 dns_server=[fdaa::3]:53
  Machine created and started in 1.918s
  05:16:47.384 [error] Postgrex.Protocol (#PID<0.167.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (markably-app-com-db.flycast:5432): non-existing domain - :nxdomain
  05:16:47.384 [error] Postgrex.Protocol (#PID<0.166.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (markably-app-com-db.flycast:5432): non-existing domain - :nxdomain
  05:16:48.616 [error] Postgrex.Protocol (#PID<0.167.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (markably-app-com-db.flycast:5432): non-existing domain - :nxdomain

How do I debug this issue?

Regards,
Michael

Added elixir

I’m also hitting this issue on an already-created db. Suddenly it stopped working. It refuses to connect and I’ve changed nothing with my DATABASE_URL since initializing

Are you still seeing this? I got sidetracked with something else and have not made a re-attempt yet.

There’s so many posts on this similar issue. Typical advice is to make sure you’re setting your IPV6 settings correctly. However I’m still hitting it despite following the advice. Frustrating…

Deploying a different app and I have no issue.

Can you look to see if there are different config options set in both apps?

Out of the box, Phoenix/Elixir doesn’t enable IPv6 support, but we turn it on for you when you run fly launch in a Phoenix app, but this might not always happen if the files we’re looking for already exist.

Specifically, rel/env.sh.eex should set these two env vars (among others):

export ERL_AFLAGS="-proto_dist inet6_tcp"
export ECTO_IPV6="true"

If those aren’t set, then Ecto won’t know how to connect to a database inside your organization’s private IPv6 network.

There may be other areas where config needs to be set – here’s the default runtime repo config from a simple generated Phoenix 1.7.14 app.

Sadly, if one of these things isn’t configured correctly, you’ll get connection issues.