Killed process blocks TCP ports

killnetstatprocess

I've had this issue on several machines. Is there some way to free this blocked port? Here is an example:

Let me explain. I've killed some JAVA-Process on SUSE Linux Enterprise Server 11 SP4, which had some ports open. I used the command "kill -9 " with root user. Now it is not possible to start the process again, because the port is still blocked. The application dies when the port is still open. But the process is definitively gone!

When I have a look with command
netstat -anop | grep -E "Sta|37941"
(also with root user), I'll get the following results:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    Timer
[...]
tcp        0      0 172.21.63.27:42034      172.21.63.28:37941      ESTABLISHED -                   keepalive (2861.75/0/0)
[...]

It shows no PID! Before killing the process, it showed the PID of the process. Is there any way to free such a "dead" port? We are always need to restart the operating system to get the application started again. But this is really, really critical in our high-availability systems… so what to do if we need to kill the process in the future? This issue also happened on other unix operating systems in the past.

Any help in solving this issue for the future would be highly appreciated. Thank you all very much in advance!

Best Answer

Try it to view which process (include PID) are using the port:

netstat -tupln |grep ":<Your_Port_Here>"

Then kill the PID (nearby process name) normally. Do not use kill command with any parameter.

kill <pid>

Note: Do not vote down if have never tried!

Related Question