a month ago
Environment: Both backend (NestJS) and Postgres running as serverless (sleep when inactive)
Issue:
When incoming traffic triggers a cold start, both services are supposed to wake up together. However, intermittently the backend wakes up successfully but Postgres remains in a sleeping state and never comes online. The only way to recover is to manually trigger a redeploy on the Postgres service.
Expected behavior:
Both services should wake up reliably when traffic arrives, regardless of which one starts first.
Actual behavior:
Race condition on cold start — the backend initializes and attempts to connect to Postgres before it has finished waking up. Since there is no wake-up coordination between services, Postgres occasionally gets "stuck" in a sleeping state without completing its startup.
Frequency:
Intermittent — happens roughly 30–40% of cold starts.
Workaround:
Manual redeploy of the Postgres service restores normal operation.
Questions:
1. Is there a way to define a wake-up dependency order between services (e.g. backend waits for Postgres to be healthy before starting)?
2. Is this a known issue with serverless Postgres on Railway?
Thanks in advance.
0 Replies
Status changed to Awaiting Railway Response Railway • about 1 month ago