I perform the following on Win7 32-Bit in the command prompt:
netstat -ano | findstr 8080
it returns with:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1896
how might I kill this process?
In windows you can use taskkill /pid 1896
See the reference at http://technet.microsoft.com/en-us/library/bb491009.aspx
Process Explorer
.
/F
. So I needed to use Process Explorer and go kill/delete all the relevant processes (which for me were 'ssh' and 'ssh-agent'.
If you are using Git BASH then you can try with below command
taskkill //pid 1896
Not the extra back slash here, otherwise it will throw error of invalid argument.
I hope it helps!!
I'm using Josep's command above in a script because we have a problem where MS werfault.exe (Dr Watson) steals port 8080 from our proxy server.
It's a great command, but the find "8080" will also find a port of e.g 18080 or a process id that has 8080 in it. Subsequently the wrong task could be killed.
Can be improved by changing the find string to ":8080 " (note the trailing space)
Thanks
Open command prompt and execute:
for /f "tokens=5" %a in ('netstat -aon ^| find ":8080" ^| find "LISTENING"') do taskkill /f /pid %a
If you want to do it in a .bat, replace %a for %%a
The source code for this kill script can be found here
The source code for the alias-initialization can be found here
The following bash script, (kill-port.sh
) successfully kills a port when called.
It is advised that you create an alias for this shell script
alias kill-port=$pathToScript/kill-port.sh
Creating an alias will enable the expression below in the terminal
kill-port 8080
#!/bin/bash
if [ "$1" ]
then
processIds=$(netstat -a -n -b -o | grep $1 | sed -e "s/[[:space:]]\+/ /g" | cut -d ' ' -f6)
{ #try
for processId in $processIds; do
taskkill /PID /F "$processId" 2>/dev/null
done
} || { # catch
for processId in $processIds; do
taskkill //F //PID "$processId"
done
}
fi
For me following works on windows 10, so you guys can also try !!
First of all, find all the process which are running ona port.
For that use following command in cmd:
netstat -ano | findstr <port_number>
After finding all the process running on a port, just use below command to terminate the process you want to terminate :
taskkill /F /pid 10608
10608 is the process which is going to be terminated.
in linux u can use for kill process permanently
kill -9 PID
ex.
I am going to kill httpd
process and httpd pid is 7452 ok.
then
#kill -9 7452
But make sure u can use this process only for linux .