I have a Phoenix app, and I’m trying to consume a REST API from another app within the same organization. According to the Fly.io documentation, I should be able to do this using https://rest-api-app-name.internal. However, when I send a GET request to this domain from my Phoenix app, I’m encountering “NXDOMAIN” errors.
I recommend doing fly ssh console to a machine in your Phoenix (consuming) app and using something like dig rest-api-app-name.internal aaaa to confirm DNS resolution is working well.
If so, the most likely problem here is that your consuming Phoenix app is not using IPv6, as .internal hostnames resolve only to ipv6 (AAAA) records. Make sure you have -proto_dist inet6_tcp in ERL_AFLAGS (e.g. set in your Dockerfile’s ENV or in rel/env.sh.eex).
If the name resolves correctly with dig, then the problem is in your application, and the most common reason we see in Phoenix apps (Elixir, really) is that they’re trying to resolve the name as IPv4 (A record) and not as IPv6 (AAAA record). The setting I suggested usually helps but if not, I suggest looking around for what to do when Elixir NXDOMAIN’s trying to resolve an AAAA-only name. I’ll check for other options on my side and let you know, but ideally this also helps you self-unblock
Another thing to try: in calls that do networky stuff, you need to pass socket_options: [:inet6] so they know to use ipv6. You know more Elixir than I do in order to identify where to put this.