Many sockets in CLOSE_WAIT Networking Origin: Network OSI layer 4 · Transport Last updated 5 Nov 2026

Networking: Thousands of sockets in CLOSE_WAIT — the application is not closing its side of the connection

The other end closed the connection, but your program never called close(), so the socket stays open.

Exact message you may see many CLOSE_WAIT connectionssockets stuck in CLOSE_WAITCLOSE_WAIT leaktcp CLOSE_WAIT too many
Seen on: Linux Java Networking

Meaning

CLOSE_WAIT is entirely local: the kernel is waiting for the application to close. It points to a connection or file-descriptor leak (missing close()/finally, unreleased HTTP responses, pooled connections). Find the process with ss -tanp, fix the leak, and watch for "Too many open files".

Common causes

  • Application never closes sockets (leak)
  • HTTP client response body not consumed/closed
  • Connection pool not releasing
  • Exception paths skip close()
  • Thread stuck so it never reaches close()

⚡ Quick fix

  1. Find the owner: ss -tanp state close-wait
  2. Fix the leak: close in finally/using/defer
  3. Restart as a stopgap and monitor the count

Detailed fix by platform

Linux

  1. ss -tanp state close-wait | awk "{print $NF}" | sort | uniq -c | sort -rn | head

How to diagnose

  1. State — CLOSE_WAIT?
  2. Process — Which one?
  3. FD limit — Near?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

arp -a shows (incomplete) — Networking: `arp -n` shows (incomplete) / Destination Host Unreachable — no ARP reply from the next hop (Networking)arp -a shows (incompl…Cannot assign requested address (EADDRNOTAVAIL) — Networking: connect: Cannot assign requested address — ephemeral port range exhausted by TIME_WAIT connections (Networking)Cannot assign request…Connections hang on large transfers (PMTU black hole) — Networking: SSH/HTTPS connects but hangs on large data — path MTU discovery black hole (Networking)Connections hang on l…High TCP retransmissions / packet loss — Networking: netstat -s: segments retransmitted / Wireshark: TCP Retransmission, TCP Dup ACK — packet loss on the path (Networking)High TCP retransmissi…MAC flapping / broadcast storm (spanning tree loop) — Networking: %SW_MATM-4-MACFLAP_NOTIF: Host is flapping between ports / broadcast storm (Networking)MAC flapping / broadc…nc/telnet hangs: firewall DROP vs REJECT — Networking: nc -vz hangs then times out — firewall silently DROPs packets (REJECT would answer "Connection refused") (Networking)nc/telnet hangs: fire…Possible SYN flooding on port 80. Sending cookies. — Networking: TCP: request_sock_TCP: Possible SYN flooding on port 80. Sending cookies. Check SNMP counters. (Networking)Possible SYN flooding…SFP link down / Loss of Signal (LOS) — Networking: Interface down — SFP transceiver Loss of Signal / no receive light (Networking)SFP link down / Loss …Many sock…

Explore the map of this error Full error map →

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