Often there are times that you have a port in use and you find that a process is using the port you need to free up or there is a port and you just need to find out who owns it. With Windows it is as easy as using netstat and tasklist commands.
Open a command prompt window and type:
netstat -a -n -o
The -a parameter displays all connections and listening ports, the -n parameter displays the addresses and port numbers in numerical form and the -o parameter will display the associated process identifier (PID) using the port. This command will produce an output similar to what is shown below
With the PIDs listed in the netstat output, you can follow up with the Windows Task List (tasklist.exe) command or Windows Manager (taskmgr.exe). You can then use the tasklist command with the specific PID that corresponds to a port in question. From the previous example, ports 80 and 443 are used by PID 1688 and 2576, so using the tasklist command will show you the process using the ports.
Running the command:
tasklist /svc /FI "PID eq 1688"
The parameter /svc displays services hosted in each process, the parameter /FI displays a set of tasks that match a given criteria specified by the filter and we then set the filter to look for a PID that equals to the PID we found with netstat.
So now we know that the scsm program is the program using port 443 and now we know which process to stop to free up the port. With these two commands you can track down ports used by processes giving issues to your system.