Networking for operators · mid
TCP ports, security groups and connection problems
Connection errors come from ports, state tables and filters. Learn TIME_WAIT and port exhaustion, and trace a timeout across routes, security groups and listeners.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- The side that closes a TCP connection first waits in TIME_WAIT (60 seconds on Linux) so stray packets from the old connection cannot enter a new one.
- Each outgoing connection to the same destination IP and port needs its own local port from net.ipv4.ip_local_port_range (32768 to 60999 by default, about 28,000 ports).
- Cannot assign requested address (EADDRNOTAVAIL) at peak means no free local port. Usual cause: a new connection for every request. Fix with keep-alive and connection pools, not only by tuning the kernel.
- Timed out means packets are dropped by filtering or routing. Refused means a reset came back.
- Client side: nc -vz host port, traceroute -T -p port, and which subnet and route table apply. Server side: ss -ltnp (is it listening on 0.0.0.0 or only 127.0.0.1), tcpdump to see if SYN arrives, and host firewall rules.
- Security groups are stateful allow-lists on the network interface, so return traffic is allowed. Network ACLs are stateless, per subnet, and checked in both directions.
- A new server in the same VPC that cannot connect: compare its security group, its subnet NACL and the database's inbound rule, which should allow the app's security group.
The red pen
Common traps: mistake → fix
Mistake: Raise the kernel port range and the problem is solved
Fix: reuse connections.
Mistake: Timed out means the service is down
Fix: it can be a filter or route.
Mistake: Security groups need a rule for return traffic
Fix: they are stateful.
Easy to hard
Questions interviewers ask, easy to hard
- Cannot assign requested address at peak: what is going on?
- What is TIME_WAIT and why does it exist?
- The app cannot reach Postgres: connection timed out. How do you find the problem?
- Security group or NACL: what is the difference?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.