Closed mathimariman closed 1 year ago
It looks like the FLY_REGION variable is causing the issue. Error: Can't reach database server at ams.db-name-here.flycast:5432
Running the command fly postgres attach --app app-name-here db-name-here
will create a database user and set the DATABASE_URL secret for the attached application.
-> This secret (DATABASE_URL) doesn't contain the FLY_REGION part (ams in my case)
In file app/db.server.ts
I see that the FLY_REGION is added to the DATABASE_URL when not running on localhost:
if (!isLocalHost) {
databaseUrl.host = ${FLY_REGION}.${databaseUrl.host}
;
if (!isReadReplicaRegion) {
// 5433 is the read-replica port
databaseUrl.port = "5433";
}
}
By removing the line which is adding the FLY_REGION (databaseUrl.host = ${FLY_REGION}.${databaseUrl.host};
, the deployment is successful again.
I have been testing with other regions as well -> same error
Following this to see why this occurred: https://community.fly.io/t/my-postgres-database-is-down-for-no-reason/12664
Following this to see why this occurred: https://community.fly.io/t/my-postgres-database-is-down-for-no-reason/12664
The link seems to be broken
It works if you're logged in.
Oh man, I spent the whole day trying to figure out what I was doing wrong... thanks for the solution!
Following this to see why this occurred: https://community.fly.io/t/my-postgres-database-is-down-for-no-reason/12664
Do you have an update on this one?
some issues are popping up again with connecting to fly DBs
Have you experienced this bug with the latest version of the template?
yes
Steps to Reproduce
npx create-remix@latest --template remix-run/blues-stack
fly apps create app-name-here
2.2 Set app secret variable:fly secrets set SESSION_SECRET=$(openssl rand -hex 32) --app app-name-here
2.3 Create database:fly postgres create --name db-name-here
2.4 Link databasefly postgres attach --app app-name-here db-name-here
Expected Behavior
Application should be deployed
Actual Behavior
Error while deploying the application:
Error: Can't reach database server at ams.db-name-here.flycast:5432