Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to do what TCPView does from the command line, for example, closing a connection used by a particular process (without ending the process). Is there a way to do this?

share|improve this question

closed as off-topic by Sven Jan 17 at 9:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers 4

up vote 2 down vote accepted - see "Closing a connection from Command-line" section (I've not tried it).

share|improve this answer

You could use hping3 to send a tcp reset from the same source port to the same destination ip/port as the connection you'd like to close. netstat -b will give you the process information.

share|improve this answer
Seems a bit heavyweight as it requires installing winpcap (driver + DLLs) as a dependency. Not sure what that would do to my system. – Jon Mar 16 '11 at 3:35

Tcpkill from dsniff performs a bruteforce on the tcp sequence to send RST to the target flow. Use it with lsof or netstat to get the open sockets, then kill them :

petrus@seth:~$ sudo lsof -i TCP:80
chromium- 2674 petrus IPv4 TCP  seth:44545->  (ESTABLISHED)

petrus@seth:~$ sudo tcpkill -9 port 44545
tcpkill: listening on eth0 [port 44545] > R 2186116153:2186116153(0) win 0 > R 2186116230:2186116230(0) win 0 > R 2186116384:2186116384(0) win 0 > R 2186116615:2186116615(0) win 0
share|improve this answer
Hmm, just saw that you installed winpcap... So I guess dsniff won't help you :( – petrus Jun 20 '11 at 22:37

You can try wkillcx.

wkillcx can close an active connection.

You can download wkillcx at:

It's freeware.

You can also view an example at the end of this post (it's in Spanish):

share|improve this answer

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