`fly postgres attach` fails with `no such host` error

Hi all! First time user, sorry if I am missing something obvious…

fly launch, after selecting Yes to “Would you like to set up a Postgresql database now?” and successfully deploying the DB app (green in the dashboard), errored out with:

Error Failed attaching mrt-apptest-db to the Postgres cluster mrt-apptest:
Get "http://mrt-apptest-db.internal:5500/commands/databases/mrt_apptest":
dial: lookup mrt-apptest-db.internal. on fdaa:0:a99c::3: no such host.
Try attaching manually with 'fly postgres attach --app mrt-apptest mrt-apptest-db'

Trying the suggested command gives the same error:

$ fly postgres attach --app mrt-apptest mrt-apptest-db
Error Get "http://mrt-apptest-db.internal:5500/commands/databases/mrt_apptest":
dial: lookup mrt-apptest-db.internal. on fdaa:0:a99c::3: no such host

Unsurprisingly, trying fly deploy anyway ends up with:

PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Other topics mention fly postgres attach failures, but with different errors, none with no such host, so starting a new topic.

[Edit: added below]

Just in case I checked the status page, but currently all systems are operational. Also, preemptively ran fly doctor:

$ fly doctor
Testing authentication token... PASSED
Testing flyctl agent... PASSED
Testing local Docker instance... PASSED
Pinging WireGuard gateway (give us a sec)... PASSED


$ fly version
fly v0.0.396 darwin/arm64 Commit: edf8f512 BuildDate: 2022-09-23T19:34:38Z

$ fly apps list
NAME                            OWNER   STATUS          PLATFORM        LATEST DEPLOY 
fly-builder-snowy-fire-8758     sandbox suspended       machines                     
mrt-apptest                     sandbox error           nomad                        
mrt-apptest-db                  sandbox running         nomad           55m8s ago    

$ fly dig txt _apps.internal
;; opcode: QUERY, status: NOERROR, id: 6173
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;_apps.internal.        IN       TXT

_apps.internal. 5       IN      TXT

I tried again and the attach worked.

I noticed one difference: the answer section to fly dig is not empty anymore today:

_apps.internal.	5	IN	TXT	"fly-builder-snowy-fire-8758,mrt-apptest,mrt-apptest-db"

So a couple of questions:

  1. Was the fly dig answer being empty the reason for the error?
  2. What can cause the fly dig answer to be empty?