n8n worker crashing
isamatiasilms
HOBBYOP

6 months ago

my n8n worker is crashing...

i receive those messages:

Connection terminated due to connection timeout

Last session crashed

$10 Bounty

1 Replies

3 months ago

1. Restart PostgreSQL First (Most Common & Fastest Fix)

  • Go to your PostgreSQL service in the Railway dashboard.
  • Click Restart.
  • After the database is fully up (wait 10–20 seconds), restart your n8n services:
    • Restart Primary
    • Restart Worker
    • Restart Webhook Processor (if you have it)

This fixes the issue for many users immediately.

2. Increase Database Connection Timeout

Add the following Environment Variable to ALL n8n services (Primary, Worker, and Webhook Processor):

text

DB_POSTGRESDB_CONNECTION_TIMEOUT=60000

(You can try 120000 for 120 seconds if 60 seconds is still not enough.)

How to add it:

  • Go to each n8n service → Variables tab → Add Variable.
  • After adding, redeploy the services.

Additional Recommended Variables (Often Needed Together)

Add these to the Primary service for better stability:

text

DB_POSTGRESDB_CONNECTION_TIMEOUT=60000
DB_POSTGRESDB_POOL_SIZE=10
DB_POSTGRESDB_MAX_POOL_SIZE=15

On the PostgreSQL service itself, you can also add these (optional but helpful for heavy usage):

text

POSTGRES_MAX_WAL_SIZE=2GB
POSTGRES_CHECKPOINT_TIMEOUT=15min
POSTGRES_CHECKPOINT_COMPLETION_TARGET=0.9

After adding any variables, Redeploy the affected services.

Next Steps if Still Crashing

  • Check the full logs of the Worker and Primary (especially during startup).
  • Make sure you're using Private Network connections between n8n services and Postgres/Redis (not public URLs).
  • If you're on the Hobby Plan, consider temporarily increasing resources (RAM/CPU) for n8n services.

Try steps 1 and 2 first.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...