Networking: Connection works, then fails after being idle — firewall/NAT idle timeout dropped the TCP session (use keepalive)
A connection that sat idle was forgotten by a firewall or NAT device, so the next packet gets reset or vanishes.
connection dropped after idleidle timeout firewall TCP sessionNAT idle timeout connection resetConnection reset after idle periodenable TCP keepalive Meaning
Stateful devices remove idle mappings after a timeout (often 60 s to 1 h; AWS NLB 350 s, Azure LB 4 min). Enable TCP keepalive with intervals shorter than that timeout, or application-level pings and reconnect logic, and lengthen the idle timeout where configurable.
Common causes
- Firewall/NAT/load-balancer idle timeout shorter than the connection's idle time
- No TCP keepalive or app heartbeat
- Default Linux keepalive of 2 hours
- Database or SSH sessions left idle
- Connection pool keeping stale connections
⚡ Quick fix
- Lower
tcp_keepalive_timebelow the device timeout - Add app-level ping/heartbeat
- Validate pooled connections before use
Detailed fix by platform
Linux
sudo sysctl -w net.ipv4.tcp_keepalive_time=240 net.ipv4.tcp_keepalive_intvl=30 net.ipv4.tcp_keepalive_probes=4
How to diagnose
- Failure — After idle time?
- Keepalive — Enabled and short enough?
- Device timeout — Known?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Networking
- Native VLAN mismatch / wrong VLAN, no connectivity Networking: %CDP-4-NATIVE_VLAN_MISMATCH / device on the wrong VLAN can't reach the gateway
- Port err-disabled (psecure-violation) Networking: %PM-4-ERR_DISABLE: psecure-violation error detected on Gi0/5, putting Gi0/5 in err-disable state
- Rogue DHCP server hands out wrong gateway/DNS Networking: Clients receive the wrong default gateway or DNS server — a rogue DHCP server (often a home router) answers first
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026