TLDR;
I want to connect to on Node.js(express).
hostname “.internal” or “.fly.dev” didn’t work at all.
How can i solve this?
Hello, i’m new to Fly.io and Postgres.
I deployed my app few days ago, and it worked successfully.
My App is based on Node.js (express), Socket.io, and I’m trying to use Postgres Database with my app.
But, i don’t know how to do this.
I tried to add codes of Node.js connection code with Connection String, and also with option objects like
https://fly.io/docs/postgres/connecting/app-connection-examples/
, but it didn’t work. There was an error.
listening on port*: 7777
node:internal/process/promises:265
triggerUncaughtException(err, true /* fromPromise */);
^
Error: getaddrinfo ENOTFOUND <my-app-db>.internal
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '<my-app>.internal'
}
I think the problem is hostname. So i’ve changed it with ‘.fly.dev’, which i can see on my dashboard. But there was an another error.
const error = this._ending ? new Error('Connection terminated') : new Error('Connection terminated unexpectedly')
^
Connection terminated unexpectedly')
Error: Connection terminated unexpectedly
at Connection.<anonymous>
When i create Postgres cluster, the log was:
Username: postgres
Password: <password>
Hostname: <my-app-db>.internal
Proxy port: 5432
Postgres port: 5433
Connection string: postgres://postgres:<password>@<my-app-db>.internal:5432
I tried another hostname with .fly.dev, but it didn’t work too.
Neither of local or deployed app doesn’t work.
How can i use with ?
My mind is almost blown up because of this, all this week.
Please help me. Thanks.