How to kill process on port on Windows when the port cannot be opened?
NickName:ENV Ask DateTime:2021-04-16T04:56:43

How to kill process on port on Windows when the port cannot be opened?

I'm on a Windows machine. Typically, when I need to kill a process on a port I do the following:

netstat -ano | findstr : <PORT>

After that command, the Process Identifier (PID) should appear and using that PID, I would do:

taskkill /PID <PID> /F

Then there's a response that the process has been terminated.

My issue now is that I'd like to kill the process on port 27017. So that I can use that port for a connection to Mongo. When I run: taskkill /PID 27017 /F I get the response FINDSTR: Cannot open 27017. Is there a way around this so that I can kill the task on that port. I've tried to restart as well, but that's not really doing me any good.

Any help would be appreciate and thanks in advance!

Copyright Notice:Content Author:「ENV」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/67115945/how-to-kill-process-on-port-on-windows-when-the-port-cannot-be-opened

More about “How to kill process on port on Windows when the port cannot be opened?” related questions

How to kill process on port on Windows when the port cannot be opened?

I'm on a Windows machine. Typically, when I need to kill a process on a port I do the following: netstat -ano | findstr : &lt;PORT&gt; After that command, the Process Identifier (PID) should appear...

Show Detail

Kill a process using a port (Windows/C)

How can I kill (or just find the pid. The killing is easy) of a process that is listening on a certain port from c/c++ on Windows?

Show Detail

How to kill a process on a port on ubuntu

I am trying to kill a process in the command line for a specific port in ubuntu. If I run this command I get the port: sudo lsof -t -i:9001 so...now I want to run: sudo kill 'sudo lsof -t -i:90...

Show Detail

How to kill a CLOSE_WAIT state process preferably by port 80 in WINDOWS with batch script

Summary: Rogue java processes from lingering stopped services preventing service from returning. Stopping a java service doesn't kill the java process on occasion, it locks it in a CLOSE_WAIT st...

Show Detail

kill a process on a specific port by name

I have a process running on port 3200, which communicates with other processes on other ports. I know I can kill a process on a given port by doing kill -9 $(lsof -t -i:3200). My problem is that ...

Show Detail

Unable to Kill Whatever Process is Running on Port 80

[***EDIT: I tried searching again with command lsof -wni tcp:80 and another process comes up with the name google but on a different port and I noticed that whenever I kill that process it just kills

Show Detail

Trying to kill process on port 8000 confusion

I am writing a Ruby script that deploys a server on port 8000 in the background, and then in the foreground I issue queries to the server. After I've issued my queries I kill the server, however wh...

Show Detail

Kill windows process that keeps restarting

I am trying to stop a windows service that is using a port I need, but the service keeps restarting it self. How do I stop it from restarting itself? I followed this question to kill it (How to ki...

Show Detail

Kill process that is taking specific port

Is is possible to programatically select process that is taking a specific port (:3000 for example) and kill it ? I do that by hand now by using netstat -tp and then I would check pid of a proce...

Show Detail

One command to kill a process using a specific port

For a project, I constantly need to find the process using a specific port and kill that process. I do this by: lsof -i :portnumber #read the pid kill -9 pid Since I do this a lot, I'm a bit bore...

Show Detail