How do I kill a process that is dead but listening?
Problem
I'm developing an app that listens on port 3000. Apparently there's an instance of it still listening to the port because whenever I start it, it can't create a listener (C#, TcpListener, but that's irrelevant) because the port is already taken. Now, the app doesn't exist in the Task Manager, so I tried to find its PID and kill it, which led to this interesting result: I haven't seen this behaviour before and figured it was interesting enough to see if anyone has a solution. UPDATE: I started up Process Explorer and did a search for 3000 and found this: I right clicked on it and chose "Close Handle". It's no longer in Process Explorer, but still shows up in netstat and still stops the app from starting the listener. UPDATE 2: Found TCPView for Windows which show the process as . Like with CurrPorts, nothing happens when I try to close the connection in this tool.
Error Output
C:\Users\username>netstat -o -n -a | findstr 0.0:3000 TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 3116 C:\Users\username>taskkill /F /PID 3116 ERROR: The process "3116" not found.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How do I kill a process that is dead but listening?
To avoid endless waits on the socket, your program should use the setsockopt function with the SO_REUSEADDR and SO_RCVTIMEO parameters :
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix