In one minute
- A fixed, step-by-step order for finding any network problem, plus
tcpdumpto look at the real packets when simple tools are not enough. - Under pressure, people guess and restart things at random. Senior engineers are not faster because they know secret commands. They are faster because they check things in the same order every time.
- Start at the bottom (does the machine have an address?) and move up one step at a time (route → name → host → port → app). Stop at the first step that fails. That is where the problem is.
- 👉 Every "can't connect", "it's slow" or "it works sometimes" problem.
Think of it like: a plumber checking for a leak. Start at the water main, then follow the pipe room by room. Do not rip out the kitchen tap before you know the water is even reaching the house.
The method: bottom up, one step at a time
Eight questions, asked in order. Stop at the first "no".
| Step | Question | Command |
|---|---|---|
| 1 | Is the network card up, with the right IP? | ip -br addr |
| 2 | Is there a route to where I am going? | ip route get DEST |
| 3 | Does the name turn into the right IP? | dig +short name, getent hosts name |
| 4 | Can I reach the machine? | ping -c 3, traceroute |
| 5 | Is the port open from here? | nc -zv host port |
| 6 | Is the service listening on the server? | ss -tulpn (on the server) |
| 7 | Does the app answer correctly? | curl -v |
| 8 | Is anything blocking in between? | Firewalls, security groups, NACLs, NetworkPolicy |
Test from both ends when you can: from the client towards the server, and on the server itself with curl localhost.
Remember it: Card → Road → Name → Reach → Port → Listening → App → Blockers.
What the error message tells you
Each error points to a different layer. Read it carefully. It is your biggest clue.
| What you see | Layer | Most likely causes |
|---|---|---|
Could not resolve host | DNS | Typo, wrong resolver, missing private DNS record |
Network is unreachable | Routing | No route, missing default gateway |
No route to host | Routing or firewall | A REJECT rule, or the host is down |
| Timeout | Something blocking | Security group, NACL, server firewall DROP, wrong route |
Connection refused | The service | Not running, wrong port, listening on 127.0.0.1 |
Connection reset by peer | Service or proxy | App crashed mid-request, idle timeout, wrong protocol |
| TLS error | TLS | Expired certificate, wrong name, missing chain |
| HTTP 502 / 503 / 504 | Behind the proxy | The app behind it is down, unhealthy or slow |
| Works sometimes | Several servers | One bad server, DNS rotation, MTU, connection-table limits |
Worked example: "the API cannot reach Redis"
ip -br addrip routedig +short example.comnc -zv 10.0.2.10 5432ss -tulpncurl -v http://localhost/health- Card and route: the app server is on
10.20.48.15/20with a default route. Fine. - DNS:
getent hosts redis.internalreturns10.20.64.40. Correct. - Port test:
nc -zv 10.20.64.40 6379times out. Something is blocking. - On the Redis server:
ss -tulpnshows127.0.0.1:6379. So even after the firewall is fixed, Redis would refuse other machines. - Two fixes: set Redis to listen on its private IP, and allow the app's subnet in the Redis security group on port 6379.
- Check again with
nc -zv, then from the app.
Notice there were two problems stacked on top of each other. Keep going until the full end-to-end test passes.
Looking at real packets: tcpdump
tcpdump shows the actual packets going in and out of a network card.
It settles arguments. It shows exactly what is happening, not what tools guess.
👉 When simple tools disagree, or a problem only happens sometimes.
sudo tcpdump -i eth0 port 443sudo tcpdump -i any -nn port 5432 # all traffic on 5432sudo tcpdump -i eth0 -nn host 10.20.64.40 # traffic to or from one hostsudo tcpdump -i eth0 -nn 'tcp[tcpflags] & tcp-syn != 0' # connection attempts onlysudo tcpdump -i eth0 -w /tmp/cap.pcap port 443 # save for Wireshark| Option | Meaning |
|---|---|
-i eth0 / -i any | Which network card to listen on |
-nn | Show numbers, not names (faster and clearer) |
-c 50 | Stop after 50 packets |
-w file | Save to a file (open it later in Wireshark) |
-A | Print the content as text (plain HTTP only) |
Reading a TCP handshake
Every TCP connection starts with a 3-step "handshake".
10.20.48.15.51234 > 10.20.64.40.6379: Flags [S] # client sends SYN10.20.64.40.6379 > 10.20.48.15.51234: Flags [S.] # server replies SYN-ACK10.20.48.15.51234 > 10.20.64.40.6379: Flags [.] # client ACK: connectedThink of it like: "Hello?" (SYN) → "Hello, I hear you" (SYN-ACK) → "Great, let's talk" (ACK).
| What you see | Meaning |
|---|---|
[S] again and again, no reply | Packets are dropped on the way (firewall, security group, route) |
[S] then [R.] | The server got it but said no: nothing listening, or a REJECT rule |
Handshake completes, then [R] | The app or proxy closed the connection |
[S] reaches the server, but the reply never reaches the client | The return path is broken: a different route back, or a NACL outbound rule |
Capturing on the client and the server at the same time shows exactly where packets disappear.
The strange cases that happen "only sometimes"
| Problem | Clue | Check |
|---|---|---|
| MTU mismatch (packet too big) | Small requests work, big ones hang (often over a VPN) | ping -M do -s 1472 host; lower the MTU |
| Connection table full | Random drops under load; nf_conntrack: table full in dmesg | sysctl net.netfilter.nf_conntrack_max |
| Run out of outgoing ports | Cannot assign requested address under heavy load | ss -s; widen ip_local_port_range; reuse connections |
| DNS delays in Kubernetes | Some requests take 5 extra seconds | CoreDNS load, the ndots setting |
| One bad server | Every Nth request fails | Test each server directly with curl --resolve |
| Different route back | SYN arrives, but the reply goes another way | ip route get on both sides, check rp_filter |
Kubernetes quick checks
kubectl get pods -o wide # pod IPs and nodeskubectl get svc,endpoints my-svc # does the Service have endpoints?kubectl exec -it debug -- nc -zv my-svc 80 # test from inside the clusterkubectl get networkpolicy -A # policies that may block trafficA Service with no endpoints means no ready pods match its label selector. That is a label typo or a failing readiness check, not a network problem at all.
Real-world scenario: works from one zone, fails from another
Requests from servers in ap-south-1a work. From ap-south-1b they time out.
ip routetraceroute example.comThe two subnets use different route tables. Subnet b's table is missing the route to the connected (peered) VPC. Comparing ip route get and the AWS route tables for each subnet finds it in minutes.
The lesson: when something works in one place and not another, compare the two setups side by side.
Common mistakes
- Starting at the top (restarting the app) before checking DNS and connectivity.
- Testing from the wrong place, such as your laptop on the VPN instead of the real client.
- Stopping at the first fix when several problems are stacked.
- Changing several things at once, so you never learn which change worked.
Practice
- Write down the eight-step playbook from memory.
- A client gets "connection refused" on port 8080. List two possible causes and the command that confirms each.
- In a
tcpdump, you see repeated SYNs and no replies. What does that tell you? - Requests over the VPN hang only for large file uploads. What would you test?
Cheat sheet
| Goal | Command |
|---|---|
| Route for one address | ip route get IP |
| What apps resolve | getent hosts name |
| Test a TCP port | nc -zv host port |
| What listens here | ss -tulpn |
| Full HTTP and TLS view | curl -v url |
| See the packets | tcpdump -i any -nn port N |
| Connection summary | ss -s |
Key takeaways
- Check network problems in the same order every time, from the bottom up.
- Stop at the first step that fails. That is where the problem is.
- The error message tells you the layer: refused, timeout and reset all mean different things.
tcpdumpshows the real packets. If the "hello" (SYN) never arrives, it is the network.- There can be more than one problem. Keep testing until everything works end to end.