How to close TCP and UDP ports via windows command line
Solution 1:
-
open
cmd
type in
netstat -a -n -o
find
TCP [the IP address]:[port number] .... #[target_PID]#
(ditto for UDP)(Btw,
kill [target_PID]
didn't work for me)
-
CTRL+ALT+DELETE and choose "start task manager"
Click on "Processes" tab
Enable "PID" column by going to: View > Select Columns > Check the box for PID
Find the PID of interest and "END PROCESS"
Now you can rerun the server on [the IP address]:[port number] without a problem
Solution 2:
If you know the port that you want to free you can sort your netstat list by looking for the specif port like this:
netstat -ano | findstr :8080
Then the pid will appear at the rigth which you can kill with taskkill.
taskkill /pid 11704 /F
Also you may want to look at this question which is specifically for localhost, but I think it is relevant: