Node.js: Error: connect ECONNREFUSED (database/service not running)
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1158:16)
at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:130:17)
Immediate Remediation
bash
sudo systemctl start postgresql
Root Cause Analysis
The client attempted to open a TCP connection to a port where no server is listening, typically because the database or service is not running or the port is incorrect.
Verification & Guardrails
- Ensure the service is installed and enabled (e.g., systemctl enable postgresql).
- Verify the port number matches your database configuration (e.g., 5432 for PostgreSQL).
- If using Docker, run `docker start <container>` instead of systemctl.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.