11

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?

7 Answers 7

12

In windows you can use taskkill /pid 1896

See the reference at http://technet.microsoft.com/en-us/library/bb491009.aspx

4
  • It tells me access is denied.
    – cryptomath
    Sep 9, 2014 at 2:22
  • 1
    Open a command prompt with the option "Run as Administrator". If you still have the same problem, then get the utility Process Explorer.
    – Marcelo
    Sep 9, 2014 at 2:28
  • Horray! After running as administrator and performing: TaskKill /PID 1896 /F it solves my problem!
    – cryptomath
    Sep 9, 2014 at 2:54
  • On Windows 10, taskkill did not work for me, even as Administrator, and even with /F. So I needed to use Process Explorer and go kill/delete all the relevant processes (which for me were 'ssh' and 'ssh-agent'.
    – Ryan
    Jan 13, 2017 at 21:48
2

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!!

1

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

1
  • Nice, thanks! :) I have edited my solution based upon your modification! Jul 17, 2017 at 10:09
1

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

1
  • 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
  • Why is there a try / catch?
    • The try block is an attempt to kill the specified port in non-gitbash environments.
    • The catch block transliterates the try block to a cygwin expression for the gitbash terminal
    • This allows the script to be ran in any bash or cygwin environment
-1

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.

1
  • 2
    This answer is pointless since it duplicates the already accepted answer.
    – xenoid
    Oct 28, 2017 at 17:48
-2

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 .

1
  • 1
    Please read the question again carefully. Your answer does not answer the original question. OP is using Windows not Linux
    – DavidPostill
    Aug 31, 2016 at 7:07

You must log in to answer this question.