Postgres database down - ECONNREFUSED
tecnopac
HOBBYOP

21 days ago

Project: orchestator-coco-production Error: server closed connection unexpectedly Impact: Production app down Time: Started ~15:12 UTC Feb 20, 2026

$10 Bounty

8 Replies

sam-a
EMPLOYEE

20 days ago

Hey! Your Postgres database service has crashed, which is causing your app to crash too since it can't connect to the database.

Here's what to do:

1. Redeploy Postgres first - Go to the Postgres service, click the three-dot menu, and select "Redeploy". Wait for it to come back healthy.

2. Once Postgres is back up, redeploy your app - Your app is crash-looping because it retries the database connection 9 times, fails, and restarts. Once Postgres is running again, redeploy the Orchestator-Coco service.

3. Check your volume usage - Your Postgres volume is 500MB. If it's getting full, that could have caused the crash. You can check usage in the volume settings and scale it up if needed.

If Postgres won't start after redeploying, let us know and we can investigate further.


Status changed to Awaiting User Response Railway 20 days ago


sam-a

Hey! Your Postgres database service has crashed, which is causing your app to crash too since it can't connect to the database.Here's what to do:1. Redeploy Postgres first - Go to the Postgres service, click the three-dot menu, and select "Redeploy". Wait for it to come back healthy.2. Once Postgres is back up, redeploy your app - Your app is crash-looping because it retries the database connection 9 times, fails, and restarts. Once Postgres is running again, redeploy the Orchestator-Coco service.3. Check your volume usage - Your Postgres volume is 500MB. If it's getting full, that could have caused the crash. You can check usage in the volume settings and scale it up if needed.If Postgres won't start after redeploying, let us know and we can investigate further.

tecnopac
HOBBYOP

20 days ago

Hi Sam, thank you for your prompt response. I followed your instructions, restarting the PostgreSQL database first and then the application, but the error persists. Regarding point 3, I checked and today the application's resource consumption increased significantly, approaching 500. Could this be the problem? If so, can I resolve it by upgrading the plan or increasing the capacity? I've attached evidence and my most recent log for your analysis. Logs: AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 43  - 02/20/2026, 10:53:57 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (5)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 37  - 02/20/2026, 10:53:57 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (3)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 37  - 02/20/2026, 10:54:00 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 43  - 02/20/2026, 10:54:00 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (6)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 37  - 02/20/2026, 10:54:03 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (5)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 43  - 02/20/2026, 10:54:03 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (7)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 37  - 02/20/2026, 10:54:06 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (6)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
    at afterConnectMultiple (node:net:1715:7)
AggregateError [ECONNREFUSED]: 
[Nest] 43  - 02/20/2026, 10:54:06 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (8)...
    at internalConnectMultiple (node:net:1134:18)
[Nest] 43  - 02/20/2026, 10:54:09 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (9)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 43  - 02/20/2026, 10:54:09 PM   ERROR [ExceptionHandler] 
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 37  - 02/20/2026, 10:54:09 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (7)...
AggregateError [ECONNREFUSED]: 
    at internalConnectMultiple (node:net:1134:18)
    at afterConnectMultiple (node:net:1715:7)
[Nest] 37  - 02/20/2026, 10:54:42 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (8)...
Error: Connection terminated due to connection timeout
    at Client._connectionCallback (/app/node_modules/pg-pool/index.js:262:17)
    at Connection.<anonymous> (/app/node_modules/pg/lib/client.js:149:18)
    at Object.onceWrapper (node:events:633:28)
    at Connection.emit (node:events:519:28)
    at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:62:12)
    at Socket.emit (node:events:519:28)
    at TCP.<anonymous> (node:net:346:12)
    at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:62:12)
    at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:62:12)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:events:519:28)
    at TCP.<anonymous> (node:net:346:12)
    at TCP.<anonymous> (node:net:346:12)

Status changed to Awaiting Railway Response Railway 20 days ago


Can you share your Postgres deployment logs?


0x5b62656e5d

Can you share your Postgres deployment logs?

tecnopac
HOBBYOP

18 days ago

Look the logs

Attachments


Postgres logs. Not your main application's logs.


tecnopac
HOBBYOP

18 days ago

haa Ok, Look:

Attachments


moseseth
HOBBY

18 days ago

1. Verify Credentials

Check your environment variables (likely in Railway or a .env file). Ensure the PASSWORD and USER match exactly what is defined in your database service.

  • Note: Your logs show the DB is using scram-sha-256 encryption. Make sure your password doesn't have special characters that might be getting escaped incorrectly in your connection string.

2. Check the Database Host

Since you are using Railway (based on the logs), ensure your DATABASE_HOST is set to the Internal Domain provided by Railway (e.g., postgres.railway.internal) rather than localhost, unless they are in the exact same Docker container.


Try this:

Note: If you have any public access domains for your Postgres service, remove them for now just in case as this process involves disabling password authentication.

  1. Install Railway CLI (https://docs.railway.com/guides/cli)

  2. Copy the SSH command by right clicking the PostgreSQL service

  3. Once you're in, type in the following command: (Copy paste this EXACTLY as written)

    sed -i 's/host all all all scram-sha-256/host all all ::\/0 trust/' /var/lib/postgresql/data/pgdata/pg_hba.conf

  4. Redeploy your database

  5. Use the SSH command again, and once you're in, type psql

  6. Type the following SQL command. my_password should be replaced with whatever it actually says in your variables tab for your password (Probably under the PGPASSWORD variable)

    ALTER USER postgres with password 'my_password';

  7. Type exit

  8. Reset your authentication settings with the following command:

    sed -i 's/host all all ::\/0 trust/host all all all scram-sha-256/' /var/lib/postgresql/data/pgdata/pg_hba.conf

  9. Redeploy your database and your other services that depend on your database.


Loading...