slikc
HOBBYOP
25 days ago
My Postgres service was crashing on repeat, so I deleted the service and created a new one.
I updated the variables on my web server to use the new local URL, but I get this issue:
[error] failed to initialize database, got error failed to connect to `user=postgres database=railway`: [fd12:228:e210:0:4000:101:b427:c1a3]:5432 (postgres.railway.internal): failed SASL auth: FATAL: password authentication failed for user "postgres" (SQLSTATE 28P01)
panic: Error connecting to database, failed to connect to `user=postgres database=railway`: [fd12:228:e210:0:4000:101:b427:c1a3]:5432 (postgres.railway.internal): failed SASL auth: FATAL: password authentication failed for user "postgres" (SQLSTATE 28P01)
goroutine 1 [running]:
vise/backend/initializers.ConnectDatabase()
/app/initializers/ConnectDatabase.go:27 +0x314
main.init.0()
/app/main.go:19 +0x25
main.init.0()
/app/main.go:19 +0x25even though the database seems to be fine, and viewing it through the database tab works fine.
I've redeployed my Postgres and web server several times and nothing seems to fix it.
1 Replies
25 days ago
Try this:
- Disable all public networking on the database if you have any, as the following steps will disable user authentication
- SSH into your database service (right click your service and select
Copy SSH Command) - Run this command:
sed -i 's/host all all all scram-sha-256/host all all ::\/0 trust/' /var/lib/postgresql/data/pgdata/pg_hba.conf(This will bypass user authentication) - Redeploy your database
- SSH again, and run the command
psql - Run
ALTER USER postgres with password '';where `` is the value of the variablePGPASSWORDin your Railway dashboard - Type
exit - Run
sed -i 's/host all all ::\/0 trust/host all all all scram-sha-256/' /var/lib/postgresql/data/pgdata/pg_hba.conf(This will re-enable user authentication) - Redeploy your database