7 days ago
Project ID: 790670f9-9194-4135-ab8a-8a6ecc5eb2ac
Environment: production
Services: daily-dispatch-quiz and Postgres (both in us-west2)
Error: App cannot connect to Postgres on private network (10.206.26.133:5432) — ECONNREFUSED even though both services are online and in the same region
What I've tried: IPv4 DNS resolution, retry logic, Postgres restart
Pinned Solution
7 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 '<PASSWORD>';where<PASSWORD>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
20 Replies
Status changed to Open Railway • 7 days ago
7 days ago
You should be using its hostname <SERVICE_NAME>.railway.internal to connect within the private network.
Is your Postgres service heathy? Are there any error logs?
7 days ago
Thanks for the suggestion. Here's what I'm seeing in the deploy logs:
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
The app is trying to connect to Postgres on that IPv6 address and getting connection refused. Postgres shows as "online" in the dashboard, but the app can't reach it.
I've tried:
Forcing IPv4 with family: 4 in the pg Pool config — didn't work
Moving server startup into the async init block — didn't work
This looks like a network connectivity issue between the app service and Postgres service. Any ideas?
7 days ago
The Railway AI agent wrote this:
Postgres logs show it crashed during startup:
FATAL: the database system is not yet accepting connections
DETAIL: Consistent recovery state has not been yet reached.
Postgres never fully started. It's stuck in recovery mode. That's why the app gets ECONNREFUSED—Postgres isn't listening.
This is a Postgres issue, not a network issue.
dhconn
The Railway AI agent wrote this: Postgres logs show it crashed during startup: FATAL: the database system is not yet accepting connections DETAIL: Consistent recovery state has not been yet reached. Postgres never fully started. It's stuck in recovery mode. That's why the app gets ECONNREFUSED—Postgres isn't listening. This is a Postgres issue, not a network issue.
7 days ago
Can I see the logs instead of the agent’s output…
7 days ago
Yes. And thanks very much for your help.
Starting Container
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌘ multiple files { path: ['.env.local', '.env'] }
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌁ auth for agents [www.vestauth.com]
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
◇ injected env (0) from .env // tip: ⌁ auth for agents [www.vestauth.com]
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌘ custom filepath { path: '/custom/path/.env' }
npm warn config production Use --omit=dev instead.
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ◈ secrets for agents [www.dotenvx.com]
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌘ override existing { override: true }
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
◇ injected env (0) from .env // tip: ◈ secrets for agents [www.dotenvx.com]
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌁ auth for agents [www.vestauth.com]
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
npm warn config production Use --omit=dev instead.
daily-dispatch-quiz@1.0.0 start
node server.js
◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
RSS: Next scheduled refresh in 60 minutes (6am Eastern).
DB init failed: connect ECONNREFUSED fd12:75ac:a7c5:1:2000:b4:e4e:1a85:5432
7 days ago
They're quite long. I'm not sure how much to show you. Here's a large sample:
2026-06-01 07:06:00.368 UTC [18276] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.370 UTC [18278] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.374 UTC [18280] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.374 UTC [18279] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.374 UTC [18279] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.390 UTC [18285] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.390 UTC [18285] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.391 UTC [18284] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.391 UTC [18284] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.411 UTC [18286] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.411 UTC [18286] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.411 UTC [18289] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.412 UTC [18281] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.437 UTC [18295] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.452 UTC [18301] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.461 UTC [18308] DETAIL: Consistent recovery state has not been yet reached.
2026-06-01 07:06:00.462 UTC [18309] FATAL: the database system is not yet accepting connections
2026-06-01 07:06:00.462 UTC [18309] DETAIL: Consistent recovery state has not been yet reached.
7 days ago
Is that what you wanted to see?
7 days ago
Thanks. Sorry, I've been offline for a bit. If I redeploy is there any way to manually back up all my data beforehand? (I'm not on the pro plan.)
7 days ago
Enable priority boarding in https://railway.com/account/feature-flags, click into your Postgres service, go to the console tab, and run a pg_dump. You can then download the dump from the file browser under the console window.
7 days ago
No luck there. Here's my situation, and my desperate hope....
Postgres crashed and recovered with a corrupted password state
The POSTGRES_PASSWORD environment variable doesn't match the password hash in the database
I'm hoping a superuser could reset the password via single-user mode or pg_hba.conf modification
I really hope to preserve the data on the volume
7 days ago
More detail on this:
I have a Postgres service where the password hash in the database doesn't match the POSTGRES_PASSWORD environment variable. The database is running but I can't connect. I need a Railway engineer to:
Access the Postgres container shell
Stop Postgres with pg_ctl stop
Temporarily set pg_hba.conf to trust authentication
Start Postgres and reset the password with ALTER USER postgres WITH PASSWORD
Restore pg_hba.conf and restart
The data is intact and I just need the password reset to access it. Please do not delete or wipe anything.
Thanks very much for your consideration.
7 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 '<PASSWORD>';where<PASSWORD>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
0x5b62656e5d
Try this: 1. Disable all public networking on the database if you have any, as the following steps will disable user authentication 2. SSH into your database service (right click your service and select `Copy SSH Command`) 3. 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) 4. Redeploy your database 5. SSH again, and run the command `psql` 6. Run `ALTER USER postgres with password '<PASSWORD>';` where `<PASSWORD>` is the value of the variable `PGPASSWORD` in your Railway dashboard 7. Type `exit` 8. 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) 9. Redeploy your database
7 days ago
Is this method different from regenerating the password in the config tab?
darseen
Is this method different from regenerating the password in the config tab?
7 days ago
Railway can't connect to the database since the password is different. OP needs to manually reset the password via shell.
0x5b62656e5d
Railway can't connect to the database since the password is different. OP needs to manually reset the password via shell.
7 days ago
You should update the message to instruct users to apply the steps through the console tab instead of SSHing into the container. It's easier to follow.
7 days ago
I want to follow up to let you know that with all of your help, I did manage to reconnect Railway (Postgres) to my database and retained my data. Thank you all so much for the assist! Couldn't have done it without you.
0x5b62656e5d
Try this: 1. Disable all public networking on the database if you have any, as the following steps will disable user authentication 2. SSH into your database service (right click your service and select `Copy SSH Command`) 3. 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) 4. Redeploy your database 5. SSH again, and run the command `psql` 6. Run `ALTER USER postgres with password '<PASSWORD>';` where `<PASSWORD>` is the value of the variable `PGPASSWORD` in your Railway dashboard 7. Type `exit` 8. 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) 9. Redeploy your database
7 days ago
Glad you got it fixed! Don't forget to mark @0x5b62656e5d's answer as the solution, so other users can benefit from it.
Status changed to Solved dhconn • 7 days ago
