Friday, 22 January 2016

ports checking and kill or stop listening ports

To list open network ports and the processes that own them with netstat, you can use this command

netstat -a

You can add the -n option to netstat to get port numbers instead of having the utility try to provide names for services:

netstat -an

command-line tool to see what ports are in use, and use a special flag that tells us which port is assigned to each Windows process identifier number. Then we can use that number to look up exactly which process it is

netstat -ab | more

This will immediately show you a list, although it’s maybe a little complicated. You’ll see the process name in the list, and you can search for it. You can also use this other method, which takes an extra step, but makes it easier to locate the actual process:

netstat -aon | more

If you look on the right-hand side, you’ll see where I’ve highlighted the list of PIDs, or Process Identifiers. Find the one that’s bound to the port that you’re trying to troubleshoot—for this example, you’ll see that, or port 80, is in use by PID 4708.

Now you can simply open up Task Manager—you might have to use the option to Show Processes for All Users, and then you’ll be able to find the PID in the list. Once you’re there, you can use the End Process, Open File Location, or Go to Service(s) options to control the process or stop it.

if port is used by important window services which is not possible to kill.
Example : port 80
you can temporarily stop listen port without killing services