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

I have a port that is blocked by a process I needed to kill. (a little telnet daemon that crashed). The process was killed successfully but the port is still in a 'FIN_WAIT1' state. It doesn't come out of it, the timeout for that seems to be set to 'a decade'.

The only way I've found to free the port is to reboot the entire machine, which is ofcourse something I do not want to do.

$ netstat -tulnap | grep FIN_WAIT1 
tcp        0  13937          FIN_WAIT1  -

Does anyone know how I can get this port unblocked without rebooting?

share|improve this question

7 Answers 7

up vote 1 down vote accepted
# record what tcp_max_orphans's current value
#set the tcp_max_orphans to 0 temporarily
echo 0 > /sys/proc/net/ipv4/tcp_max_orphans

# watch /var/log/messages
# it will split out "kernel: TCP: too many of orphaned sockets"
# it won't take long for the connections to be killed

# restore the value of tcp_max_orphans whatever it was before. 
echo $whateveritwas > /sys/proc/net/ipv4/tcp_max_orphans

verify with 
netstat -an|grep FIN_WAIT1
share|improve this answer

You should be able to set the timeout with /proc/sys/net/ipv4/tcp_fin_timeout.

There really doesn't seem to be any way to clear the socket manually.

share|improve this answer
This answer is not correct. tcp_orphan_retries affects FIN_WAIT1, tcp_fin_timeout affects FIN_WAIT2. –  jamieb Jun 26 '13 at 4:49
suprjami is correct, tcp_fin_timeout affects FIN_WAIT2. Which is only triggered when using SO_LINGER. –  Matt May 15 '14 at 2:32
@innaM Can you please remove this answer? It is not correct and accumulating downvotes. I see that you are still active, therefore it seems to make the most sense to remove the answer. –  Andrew B Sep 10 '14 at 14:07
@Andrew B: Seems that it's not possible to delete accepted answers. –  innaM Oct 11 '14 at 12:40

It seems that tcp_orphan_retries setting controls how many attempts will be done before a server-less port is released. It was 0 here, after setting it to 1 the ports were gone.


share|improve this answer
Thanks! Your answer is the correct one. Problem solved. –  jjrv Feb 23 '12 at 12:44
Closely related: 0 is a default which means 8. serverfault.com/a/408882/152073 –  Andrew B Sep 10 '14 at 16:44

/proc/sys/net/ipv4/tcp_fin_timeout is the timeout of the FIN-WAIT-2 state, not FIN-WAIT-1. You should go with the tcpkill route or you can try to play with the keepalive times under /proc/sys/net/ipv4/tcp_keepalive_* to force a kill by the SO.

share|improve this answer


The application on local machine has closed the connection. Indication of this has been sent to the remote machine.

You application has closed its side of the connection, the socket is now waiting for the remote side to confirm that close. If you have a problem with a lot of those sockets being held in *FIN_WAIT1* then you should follow Manni's advice above.

share|improve this answer

this may help:

net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_retries2 = 2
net.ipv4.tcp_orphan_retries = 1
net.ipv4.tcp_reordering = 5
net.ipv4.tcp_retrans_collapse = 0
share|improve this answer
It may help if you explain what all that is. We are professionals, and as such, we do not blindly paste stuff in and hope it helps. –  Michael Hampton Mar 23 '13 at 6:38

Your Answer


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.