Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

A colleague of mine recently ran into a problem where a process that had supposedly died was still bound to a network port, preventing other processes from binding to that port. Specifically, netstat -a -b was reporting that a process named System with PID 4476 had port 60001 open, except no process with PID 4476 existed, at least as far as I could tell.

Process Explorer and Task Manager did not list PID 4476 (though there was another process named System with PID 4, which had its own set of TCP connections that did not include 60001). taskkill /PID 4476 also reported that PID 4476 could not be found.

Is there a way to kill this mysterious System process to free up the port to which it's currently bound? What can cause this to happen? How can there be processes that none of Task Manager, Process Explorer, and taskkill don't know about? Rebooting managed to fix the problem, but I'd like to know if there's a way to fix this without rebooting.

share|improve this question
    
How long did you wait to see if the port was released? What state was the connection (port) in? Established, Closed, Time_Wait? –  joeqwerty Sep 14 '10 at 14:45
    
@joeqwerty: We waited at least 15-20 minutes. Unfortunately I forget what state the connection was in =/. –  Adam Rosenfield Sep 14 '10 at 14:46
    
20 minues sounds like a problem. The next time it occurs run netstat and check the state of the connection, that will give you a clue as to what's happening. As you commented to mfinni's answer though, it may be a result of your software\service crashing. –  joeqwerty Sep 14 '10 at 15:06
add comment

3 Answers

I know this is an old thread, but in case anyone else is having the same issue, I had...

What may be happening is that your process had a TCP port open when it crashed or otherwise exited without explicitly closing it. Normally the OS cleans up these sorts of things, but only when the process record goes away. While the process may not appear to be running any more, there is at least one thing that can keep a record of it around, in order to prevent reuse of its PID. This is the existence of a child process that is not detached from the parent.

If your program spawned any processes while it was running, try killing them. That should cause its process record to be freed and the TCP port to be cleaned up. Apparently windows does this when the record is released not when the process exits as I would have expected.

share|improve this answer
    
Thank you, good sir. I can't believe this answer is so low, especially since the google query is filled with answers "use TCPView/use netstat & taskkill" that do not help in this case. In my case what helped was running ProcessExplorer and looking for any process that had been orphaned. Shutting them down solved the problem. –  gwiazdorrr Jun 18 '12 at 9:13
1  
Thanks for your hint!! Killing orphand process really solved the problem. –  Darkthread May 22 '13 at 3:34
add comment

Did you try using TCPView and closing the connection? I don't know if it will show the connection in the scenario you're describing, because I've never had that happen to me. But it's the only thing I can think of if this happens again.

What was the process - was it commercial software, or something homegrown? It appears that port 60001 is used by some Trojans - I wonder if it could have been a rootkit or something that could hide itself from the OS? Might want to give that machine a good once-over with AV, maybe something from bootable media.

share|improve this answer
    
No, we didn't try TCPView; I'll keep that in mind for the future if it ever happens again. The software is our in-house software that uses port 60001 -- I'm almost certain that the process holding the port open was a previous instance of our software that somehow didn't quite fully die. That prevented another copy of the software from launching. –  Adam Rosenfield Sep 14 '10 at 14:51
    
Your application can set the SO_REUSEADDR option of the socket to true before binding it. That should solve your problem (it's even more or less mandatory on *nix) –  Stephane Sep 14 '10 at 15:06
add comment

ps -ef | grep processname

kill the related processes

kill -9 pid pid

Worked in my case

share|improve this answer
    
this question is about Windows, not Linux –  longneck Feb 21 '13 at 11:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.