25

On Linux we can kill an Established TCP Connection using tcpkill command.


For example, to drop all connection to/from a particular IP:

tcpkill host ipaddr

Or similary to kill all connection using port 21 at ethernet-1, by:

tcpkill -i eth1 port 21  

Similarly, i want to know what is the command to kill certain connection on windows, precisely windows 7. Like i can see a list of active connections by netstat -n, now i am wondering how to drop a particular or group of connections?

1

3 Answers 3

8

The CurrPorts tool from Nirsoft seems to do that. Follow the link and search for 'Closing a Connection From Command-Line'.

2
  • thanks, it seems to have licensing issues, dosen't look like free to me
    – Johnydep
    Feb 2, 2012 at 16:13
  • 3
    from the product page: "This utility is released as freeware. You are allowed to freely distribute this utility via floppy disk, CD-ROM, Internet, or in any other way, as long as you don't charge anything for this. If you distribute this utility, you must include all files in the distribution package, without any modification !" that seems pretty free to me. Feb 2, 2012 at 17:34
29

The Windows Sysinternals Suite contains a tool called TcpView. TcpView will show you all of the connections on your machine similar to netstat. It will also allow you to close the connection or kill the process hosting the connection.

7
  • 2
    thanks but I am more interested in something that is available as command line options because i need to integrate that in my application. I looked at Tcpvcon.exe which is shipped with Tcpview but i do not know how to close connection using that. Since on GUI, we simply right click and close connection, wondering how to do the same for this command line tool? Any idea/
    – Johnydep
    Feb 1, 2012 at 14:34
  • If you need to do it programmatically, use a Windows api.
    – ZippyV
    Feb 1, 2012 at 15:22
  • 1
    @ZippyV, which API i should be looking at?
    – Johnydep
    Feb 2, 2012 at 16:11
  • @Johnydep, Post the question on Stackoverflow. It will be answered in minutes hopefully.
    – Pacerier
    Jan 23, 2015 at 15:51
  • My system, while TcpView is running, is super sluggish. E.g. Alt-Tab is sloooow and painful. CurrPorts, suggested by Peter Hahndorf does not have this problem. Mar 12, 2015 at 5:00
-1

CurrPorts (cports.exe) from Nirsoft provides a Windows interface to close the ports or at least to identify the processes that are holding it open. This is a pretty good debugging tool - helped me anyway:

Using CurrPorts

The main window of CurrPorts displays the list of all currently opened TCP and UDP ports. You can select one or more items, and then close the selected connections, copy the ports information to the clipboard, or save it to HTML/XML/Text file. If you don't want to view all available columns, or you want to change the order of the columns on the screen and in the files you save, select 'Choose Column' from the View menu, and select the desired columns and their order. In order to sort the list by specific column, click on the header of the desired column.

http://www.nirsoft.net/utils/cports.html

1
  • 1
    This seems to be the same answer as another one already given 3 years before, with exactly the same link.
    – Pacopaco
    Apr 27, 2018 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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