T The Triage ManualTechnical Guides for IT Emergencies
P2 · Network Infrastructure

Connection Refused / Connection Timeout — TCP Network Connectivity Failure to Remote Service or Host

Connection refused and connection timeout errors indicate TCP connection establishment failures to a target service. Connection refused means the target host is reachable but no process is listening on the port; connection timeout means the host is unreachable or packets are being dropped. Resolution requires systematic diagnosis of service health, port binding, firewall rules, DNS resolution, and network path before applying targeted fixes.

Indicators

Likely causes

Diagnostic steps

  1. Check whether the target service process is running and listening on the expected port. Linux: `ss -tlnp | grep <port>` — Windows: `netstat -ano | findstr <port>`
    Determines if the failure is caused by the service not running or not binding to the correct interface/port
  2. Attempt a raw TCP connection from the client host to the target host and port: `nc -zv <target-host> <port>` or `telnet <target-host> <port>`
    Distinguishes between 'connection refused' (port closed) and 'connection timeout' (packet dropped or host unreachable)
  3. Verify DNS resolution of the target hostname from the client host: `dig <target-hostname>` (Linux) or `nslookup <target-hostname>` (Windows)
    Confirms the client is resolving the target hostname to the correct IP address; a stale DNS record can cause connections to the wrong host
  4. Trace the network path from the client to the target host: `traceroute <target-host>` (Linux/macOS) or `tracert <target-host>` (Windows)
    Identifies network hops, firewalls, or routers that are dropping traffic before it reaches the target
  5. Check host-based firewall rules on the target host. Linux: `iptables -L -n -v | grep <port>` — Windows: `Get-NetFirewallRule | Where-Object {$_.Enabled -eq 'True'} | Get-NetFirewallPortFilter | Where-Object {$_.LocalPort -eq '<port>'}`
    Determines whether a local firewall (iptables, nftables, Windows Firewall, ufw) is blocking the connection at the target
  6. Review recent logs from the target service for crash messages, bind errors, or listen failures: `journalctl -u <service-name> --since '30 minutes ago'` (Linux systemd) or check application log files directly
    Reveals whether the service failed to start, crashed, or explicitly refused connections due to an application-level error

Resolution path

Prevention

Tools

References

networkingtcpconnection-refusedconnection-timeoutfirewalldnsservice-availabilityincident-responselinuxwindowsmicroservicesconnectivityport-reachabilityload-balancerhealth-check