Common causes
- The database, cache, or API server your app depends on isn't running
- Wrong host or port in your config — connecting to port 5432 when your database is on 5433
- The service is running but on a different network interface (0.0.0.0 vs 127.0.0.1)
- A Docker service isn't started or the container name doesn't resolve
How to fix it
- Start the required service (e.g. database): sudo systemctl start postgresql or docker-compose up
- Verify the host and port in your .env or config file match what the service is actually using
- Test connectivity manually: nc -zv localhost 5432 or telnet localhost 5432
- For Docker: make sure you're using the container name not localhost when connecting between containers
Example
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
errno: -111,
code: 'ECONNREFUSED'Starting a Node.js API server that connects to PostgreSQL when the database isn't running
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
