Back to error codes
ERROR ECONNREFUSED
ECONNREFUSED, Connection Refused
Node.js Error
The connection to a remote host was refused because nothing is listening on the target port.
Root Cause
The target service (database, API, Redis) is not running, is on a different port, or is blocked by a firewall.
How to Fix
Verify the target service is running and listening on the expected port. Check the host and port in your connection configuration.
Quick Summary
ECONNREFUSED means nothing is listening on the target host:port. Verify the service is running, check the host/port configuration, and ensure no firewall is blocking the connection.
Key Takeaways
Key Takeaways
- The target service is not running or not listening on the expected port
- Check the service status: systemctl status postgresql
- Verify the host and port in your connection string
- Check firewall rules if the service is on a remote host
Use Cases
When to use it
- Database is not running
- Redis is not started
- Wrong port in connection string
Watch out
Common Mistakes
- Hardcoding localhost when the service is on a different host in production
- Not checking if the service is running before connecting
FAQ
ECONNREFUSED ECONNREFUSED, Connection Refused, Frequently Asked
How do I check if PostgreSQL is running?
systemctl status postgresql (Linux) or pg_ctl status -D /usr/local/var/postgresql (macOS with Homebrew).
Still having issues?
Check your network logs or use our developer tools to inspect headers, decode tokens, or validate your requests.