I’ve set up a node app and a Fly Postgres instance and the latter is attached to the former. However, I’m unable to connect the node app to the postgres instance using the process.env.DATABASE_URL
value, which was generated automatically for me by Fly. Here’s the redacted error:
Error: getaddrinfo ENOTFOUND postgres://<db_user>:<db_password>@<app-name>-db.flycast:5432/<db_name>?sslmode=disable
2024-10-03T16:29:29Z app[3d8d313c030708] lhr [info] at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
What’s especially odd is that I can use fly ssh console
to open a shell in the app VM and from there use the nodeJS REPL to connect successfully to the database using the value of process.env.DATABASE_URL
. Likewise I can connect via the Fly proxy from my local machine. So I can’t understand why the main application process can’t resolve the URL.