Unable to re-attach Postgres Database

I’m having trouble with my Postgres clusters. My latest deploy could not resolve the internal Postgres hostname hrmfitclub-stage-db.internal so I detached and attempted to re-attach my postgres cluster - now the reattach doesn’t work

fitclub_server master % flyctl postgres attach -v -a hrmfitclub-stage --postgres-app hrmfitclub-stage-db
WARN app flag 'hrmfitclub-stage' does not match app name in config file 'hrmfitclub-prod'
? Continue using 'hrmfitclub-stage' Yes
Oops, something went wrong! Could you try that again?

Help?

Do you have the admin credentials stored still? This happens because it fails to create a new database for your app since a DB with the same name already exists. If you connect and drop the old DB you can re-attach with the same name.

Alternatively, you can pass --database-name to the attach command to override it.

I’m not sure I understand your question:

Do you have the admin credentials stored still?

I did try to add the --database-name - still doesn’t work:

fitclub_server master % flyctl postgres attach -v -a hrmfitclub-stage --postgres-app hrmfitclub-stage-db --database-name hrmfitclub_stage
WARN app flag 'hrmfitclub-stage' does not match app name in config file 'hrmfitclub-prod'
? Continue using 'hrmfitclub-stage' Yes
Oops, something went wrong! Could you try that again?

Adding a bit more info - it seems like the DNS is where the issue lies.

While connected to my Organization via Wireguard - I cannot connect to the Database via the internal hostname:

psql $DATABASE_URL ← hangs

telnet hrmfitclub-stage-db 5432 ← does not resolve

fitclub_server master % dig aaaa hrmfitclub-stage-db.internal

; <<>> DiG 9.10.6 <<>> aaaa hrmfitclub-stage-db.internal
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11652
;; flags: qr rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;hrmfitclub-stage-db.internal.	IN	AAAA

;; ANSWER SECTION:
hrmfitclub-stage-db.internal. 300 IN	AAAA	fdaa:0:285f:a7b:81:0:2b0b:2
hrmfitclub-stage-db.internal. 300 IN	AAAA	fdaa:0:285f:a7b:7d:0:2b0c:2

;; Query time: 76 msec
;; SERVER: fdaa:0:285f::3#53(fdaa:0:285f::3)
;; WHEN: Fri Jul 30 15:24:45 CDT 2021
;; MSG SIZE  rcvd: 102

I am also having some issues detaching and reattaching PG apps - Unknown error is shown :frowning:

Any suggestions?

I was never able to solve this :frowning:

I ended up destroying all of my apps and re-creating everything from scratch. Haven’t had any issues since.

I ended up destroying the DB as well to fix this issue :frowning:

Obviously this wont be an option in the future.