- Networking
- Troubleshooting
- Intermediate
- 9 min read
Network errors look alike in a log, but each one points to a different place in the request path. “Connection refused” means the server answered and said no. “Connection timed out” means nobody answered at all. Knowing which step failed tells you where to look first, and saves a lot of guessing during an outage.
Last updated: December 2026
In short
- A request goes through DNS, routing, firewalls, the server port, TLS and then the open connection.
- Each error code belongs to one of those steps, so the code tells you where to start.
- Refused = the host is reachable but nothing listens. Timed out = packets are being dropped on the way.

About the names
The codes below are the ones Node.js and Linux show. Other tools describe the same problem in their own words: curl says “Could not resolve host” or “Failed to connect”, Python raises ConnectionRefusedError, and Java throws ConnectException. The meaning is the same.
DNS Network Errors
01 ENOTFOUND: The Name Does Not Exist
The DNS server answered, and the answer was “no such name” (in DNS terms, NXDOMAIN). Retrying will not help until the name or the record is fixed.
Check first: spelling of the host name, that the record exists in your DNS zone, and whether it lives in a private zone that only answers inside your VPC or office network.
dig api.example.comLook for status: NXDOMAIN in the output. If you see NOERROR but no answer, the name exists but has no record of that type (for example no IPv4 address); Node.js reports that as ENOTFOUND too.
02 EAI_AGAIN: DNS Did Not Answer in Time
The lookup did not finish. The resolver was slow, overloaded or unreachable, so the name is unknown rather than missing. A retry may work, but if it keeps happening the resolver needs attention.
Check first: which resolver the machine uses, whether it can reach it, and in Kubernetes whether the CoreDNS Pods are healthy.
cat /etc/resolv.confkubectl -n kube-system get pods -l k8s-app=kube-dnsNetwork Path Errors
03 ENETUNREACH: No Route to That Network
Your own machine has no route that leads to the destination network, so the packet never leaves. Common causes are a missing default route on the host, a network interface that is down, or a VPN route that was removed. (In AWS, a private subnet without a NAT gateway does not give this error: the instance still has a route to the VPC router, so the connection times out instead.)
ip route get 10.20.0.5If this prints “Network is unreachable”, add or fix the route. Otherwise it shows which gateway and interface the packet would use.
04 EHOSTUNREACH: No Path to That Host
A route exists, but the host cannot be reached. A router on the way reported that it cannot deliver the packet, the host is on your own subnet and does not answer at all (for example it is switched off), or the host’s firewall rejects the connection with a “host prohibited” message, which is the default reject type in firewalld and iptables. Linux shows this error as “No route to host”.
Check first: that the host is running, that it answers on your local network (ip neigh shows whether its MAC address was found), and the host firewall rules.
traceroute 10.20.0.505 ETIMEDOUT: Nobody Answered
Your connection request went out, and nothing came back before the time limit. Something on the way dropped the packets without telling anyone. In AWS this is the classic sign of a security group or network ACL that does not allow the traffic, because both drop blocked packets silently.
Check first: the inbound rule on the target’s security group, the network ACLs in both directions, the route tables (including a NAT gateway for private subnets, and VPC peering or Transit Gateway routes on both sides), and whether the server is running at all.
nc -zv -w 5 10.20.0.5 443If nc waits and then gives up, packets are being dropped. If it fails at once with “refused”, the path is fine and the problem is on the server (see the next section).
Host and Port Errors
06 ECONNREFUSED: The Server Said No
The host is reachable and answered at once, but nothing is listening on that port. The app is stopped, listens on a different port, or listens only on 127.0.0.1 instead of 0.0.0.0, so it cannot be reached from outside. A firewall rule that rejects with a TCP reset can also cause it.
Check first, on the server: is the app running, and which address and port does it listen on?
sudo ss -tlnpAn address of 127.0.0.1:3000 means only the server itself can connect; 0.0.0.0:3000 or *:3000 means everyone allowed by the firewall can.
07 ECONNRESET: The Connection Was Killed
The connection was open, then the other side cut it hard instead of closing it normally. The app may have crashed or restarted, or a load balancer or proxy closed a connection that was idle for too long.
Check first: server logs and restarts around the time of the error, and idle timeouts. An AWS Application Load Balancer closes idle connections after 60 seconds by default, so the app’s own keep-alive timeout should be longer than that.
08 EADDRINUSE: The Port Is Already Taken
This one happens when your app starts, not when it connects. It tried to listen on a port that another process already uses, often an older copy of the same app that did not stop.
sudo ss -tlnp | grep ':3000'The output shows the process name and PID that owns the port. Stop that process or choose another port.
09 EPIPE: Writing to a Closed Connection
Your program sent data on a connection that the other side had already closed (“broken pipe”). It usually means the client gave up first, for example because of its own timeout, while the server was still working on a slow response.
Check first: client and proxy timeouts, keep-alive settings, and slow requests that take longer than the client is willing to wait.
TLS Errors
10 CERT_HAS_EXPIRED: The Certificate Is Out of Date
The connection works, but the server’s TLS certificate is past its end date, so the client refuses to trust it. Less often, the server is fine and the client’s clock is wrong.
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -enddateThe notAfter date is when the certificate expires. Renew it, and set up automatic renewal and an expiry alert so it does not happen again.
Which Operating System Supports These Commands
The commands above are written for Linux, where most servers and containers run. Each box shows where it works. macOS has most of the same tools, and Windows has its own PowerShell commands for the same checks:
| Check | Linux | macOS | Windows (PowerShell) |
|---|---|---|---|
| Look up a name in DNS | dig api.example.com | dig api.example.com | Resolve-DnsName api.example.com |
| Which DNS server is used | cat /etc/resolv.conf | scutil --dns | Get-DnsClientServerAddress |
| Route to an IP address | ip route get 10.20.0.5 | route get 10.20.0.5 | Find-NetRoute -RemoteIPAddress 10.20.0.5 |
| Trace the path | traceroute 10.20.0.5 | traceroute 10.20.0.5 | tracert 10.20.0.5 |
| Test if a port answers | nc -zv -w 5 10.20.0.5 443 | nc -zv -w 5 10.20.0.5 443 | Test-NetConnection 10.20.0.5 -Port 443 |
| What listens on which port | sudo ss -tlnp | sudo lsof -nP -iTCP -sTCP:LISTEN | Get-NetTCPConnection -State Listen |
| Certificate expiry date | openssl s_client ... | openssl s_client ... | openssl from Git for Windows, or use WSL |
| Kubernetes DNS Pods | kubectl | kubectl | kubectl |
Missing a command?
Small Linux images often leave out dig, nc and traceroute. On Ubuntu and Debian install dnsutils, netcat-openbsd and traceroute; on Amazon Linux, RHEL and Fedora install bind-utils, nmap-ncat and traceroute. On Windows, the Windows Subsystem for Linux (WSL) lets you run every Linux command in this guide.
Network Errors Quick Reference
| Error | Step | What it means | Check first |
|---|---|---|---|
ENOTFOUND | DNS | No address found for the name | Spelling, DNS record, private zone |
EAI_AGAIN | DNS | DNS too slow or unreachable | Resolver, CoreDNS |
ENETUNREACH | Route | No route to the network | Default route, interface, VPN |
EHOSTUNREACH | Route | No path to the host | Host up, ARP, host firewall |
ETIMEDOUT | Network path / firewall | Packets dropped | Security group, NACL, routes |
ECONNREFUSED | Port | Nothing listens | App running, port, bind address |
ECONNRESET | Open connection | Other side cut the connection | Crashes, idle timeouts |
EADDRINUSE | Port (server) | Port already taken | Old process on that port |
EPIPE | Open connection | Wrote after the other side closed | Client timeouts, keep-alive |
CERT_HAS_EXPIRED | TLS | Certificate out of date | Expiry date, client clock |
Key takeaways
- Read the error code first: it tells you which step of the request failed.
- Refused means the server is reachable; look at the app and its port.
- Timed out means packets are dropped; look at firewalls, routes and whether the host is up.
- DNS errors come before any connection, and TLS errors come right after it.
FAQ
What is the difference between connection refused and connection timed out?
Refused is a fast “no” from a reachable host with nothing listening on the port. Timed out means no reply came at all, usually because a firewall or missing route dropped the packets.
Why do I get a timeout instead of refused in AWS?
Security groups and network ACLs drop blocked traffic silently instead of rejecting it, so the client only sees a timeout.
Is ENOTFOUND the same as NXDOMAIN?
Almost. NXDOMAIN is the DNS server’s answer that the name does not exist. ENOTFOUND is how Node.js reports a lookup that found no address, which is usually caused by NXDOMAIN.
Should my app retry on these errors?
Retrying with a short wait helps for temporary ones such as EAI_AGAIN, ETIMEDOUT and ECONNRESET, but only for requests that are safe to repeat. Retrying a payment or another POST after a reset can do it twice. It does not help for ENOTFOUND, EADDRINUSE or an expired certificate, which need a fix first.
For the official meaning of the most common codes, see the common system errors in the Node.js documentation.
Inspired by an infographic shared by DevOps Shack. Diagram and text by infotechtu.com.
Related guides on infotechtu.com
Share this guide
Get new guides by email
One short email when a new guide is out. Unsubscribe at any time.
