10 Network Errors Explained: Refused vs Timed Out and More

  • 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.
Network errors mapped to the step where they happen: DNS, route, firewall, port, TLS and open connection
Where each error happens on the way from your app to the server. Tap the picture to see it full size.

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

  • DNS

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.

Linux · macOS
dig api.example.com

Look 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

  • DNS
  • Often temporary

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.

Linux
cat /etc/resolv.conf
Any OS with kubectl
kubectl -n kube-system get pods -l k8s-app=kube-dns

Network Path Errors

03 ENETUNREACH: No Route to That Network

  • Network path

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.)

Linux
ip route get 10.20.0.5

If 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

  • Network path

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.

Linux · macOS
traceroute 10.20.0.5

05 ETIMEDOUT: Nobody Answered

  • Network path
  • Most common in the cloud

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.

Linux · macOS
nc -zv -w 5 10.20.0.5 443

If 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

  • Host and port

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?

Linux
sudo ss -tlnp

An 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

  • Host and port

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

  • Host and port
  • On the server

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.

Linux
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

  • Host and port

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

  • TLS

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.

Linux · macOS
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -enddate

The 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:

CheckLinuxmacOSWindows (PowerShell)
Look up a name in DNSdig api.example.comdig api.example.comResolve-DnsName api.example.com
Which DNS server is usedcat /etc/resolv.confscutil --dnsGet-DnsClientServerAddress
Route to an IP addressip route get 10.20.0.5route get 10.20.0.5Find-NetRoute -RemoteIPAddress 10.20.0.5
Trace the pathtraceroute 10.20.0.5traceroute 10.20.0.5tracert 10.20.0.5
Test if a port answersnc -zv -w 5 10.20.0.5 443nc -zv -w 5 10.20.0.5 443Test-NetConnection 10.20.0.5 -Port 443
What listens on which portsudo ss -tlnpsudo lsof -nP -iTCP -sTCP:LISTENGet-NetTCPConnection -State Listen
Certificate expiry dateopenssl s_client ...openssl s_client ...openssl from Git for Windows, or use WSL
Kubernetes DNS Podskubectlkubectlkubectl

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

ErrorStepWhat it meansCheck first
ENOTFOUNDDNSNo address found for the nameSpelling, DNS record, private zone
EAI_AGAINDNSDNS too slow or unreachableResolver, CoreDNS
ENETUNREACHRouteNo route to the networkDefault route, interface, VPN
EHOSTUNREACHRouteNo path to the hostHost up, ARP, host firewall
ETIMEDOUTNetwork path / firewallPackets droppedSecurity group, NACL, routes
ECONNREFUSEDPortNothing listensApp running, port, bind address
ECONNRESETOpen connectionOther side cut the connectionCrashes, idle timeouts
EADDRINUSEPort (server)Port already takenOld process on that port
EPIPEOpen connectionWrote after the other side closedClient timeouts, keep-alive
CERT_HAS_EXPIREDTLSCertificate out of dateExpiry 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

Save

Get new guides by email

One short email when a new guide is out. Unsubscribe at any time.

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top