What process is running on port windows

How to Check Which Process Is Using Port 8080 or Any Other Port (and Vice Versa) on Windows

Learn how to see which process or application is using a particular port, and likewise, which port is being used by a particular process.

Join the DZone community and get the full member experience.

Hello friends. In this tutorial, you will learn

  • How to check which process/application is using a particular port on Windows
  • How to check which port is being used by a particular process/application on Windows

How to Check Which Process/Application Is Using a Particular Port on Windows

Step 1 — Find the Process id of the Process Using the Given Port

Syntax

netstat -aon | findstr

-a Displays all connections and listening ports.

-o Displays owning process Id associated with each connection.

-n Displays addresses and port numbers in numerical forms

On my system, it displays the following output. My Tomcat is up and running on port 8080 within Eclipse and I executed the following command.

netstat -aon | findstr 8080

Here the last column is telling the process id of the process which is using port 8080.

Explanation

netstat -aon

Will give you a list of process Ids which are using given port.

findstr 8080

findstr is functionally equivalent to grep command on Linux. From the output of netstat, findstr will give the lines which have word 8080 in it.

Step 2 — Find the Process/Application Name Using the Given Port Using the Process id Found in Step 1

Syntax

This will give you the application name which is using that port.

On my system, I used the following command to check which process belongs to process id 9260.

tasklist | findstr 9260

Here, javaw.exe is the process which is using port 8080.

How to Check Which Port Is Being Used by a Particular Process/Application on Windows

Step 1 — Find the Process id of the Process Using a Process With the Given Name

Syntax

On my system, I executed the following command to find first process id of a process with name javaw.exe

Читайте также:  Stop code inaccessible boot device windows 10 как исправить

tasklist | findstr javaw.exe

Here, 9260 is the process id of the process javaw.exe.

Step 2 — Find the Port Being Used by the Process id Found in Step 1

On my system, to find which port is being used by a process with process id 9260, I run

netstat -aon | findstr 9260

As you can see in the above output, process 9260 is using port 8080.

Summary

In this tutorial, you learned

Use of the netstat command with -aon options together with the findstr command to find out which process is using a particular port, and vice versa.

Thanks for reading. Share it with someone you think it might help.

Published at DZone with permission of Gaurav Bhardwaj . See the original article here.

Opinions expressed by DZone contributors are their own.

How do I determine which process is using a serial port?

The company I work for makes hardware that communicates to the computer though a serial port. Third party companies write software that communicates with our hardware.

There are times when I need to diagnose our hardware. However, a third party software app connects to the serial port when Windows starts up, blocking any other connection. I don’t know the name of this application/service and it’s not always the same one.

Is there any way to either:

  • Find the name/pid of the app/service that is currently using a given serial port or
  • Steal the serial port connection from another app.

vb.net preferably, but I’ll take a language agnostic answer as well.

3 Answers 3

You can use the process explorer tool also from SysInternals to search for open handles. In this case you would want to search for ‘Serial’ since it uses device names that may not map to com port numbers. (e.g. COM1 is \Device\Serial0 on my system).

If you want to take control of the serial port from another app I think you would need co-operation of the driver.

As Rob Walker said, you can find who’s using a serial port using Process Explorer. Most of the time, typing Ctrl + F and searching for «serial» will show you who has a serial port open, but I just ran into a situation where my «COM3» serial port’s handle appeared as «\Device\VCP0». It may be strange because it was running under VirtualBox with a USB-to-serial connector.

If searching for «serial» and «device\vcp» don’t get you any results, you may be able to figure out how serial port handles are named by opening one with a known program. In Process Explorer, display the lower pane with each process’s open handles by typing Ctrl + L . Click on the process that you used to open the serial port and look through the lower pane to see which handles look like they might be a serial port. You can open and close the port while you’re looking, and the file handle should appear and disappear, as well as being highlighted in green or red. Of course, this is only possible if you have more than one serial port or the serial port you’re trying to diagnose isn’t always locked by some mystery process.

Читайте также:  Как включить максимальную производительность windows 10 если ее нет

Sysinternals has a slew of utilities I find very useful and educational for tracking down what processes are doing to the system.

They have a utility that does exactly what you need called Portmon, and give some information on how it works near the bottom of the page. That info and a few well-asked questions will probably give you everything you need to implement it yourself if the utility isn’t enough.

Find the PID of a process that uses a port on Windows

My service crash on startup with the classic:

How can I find the process for killing it?

7 Answers 7

Just open a command shell and type (saying your port is 123456):

You will see everything you need.

The headers are:

Find the PID of a process that uses a port on Windows (e.g. port: «9999»)

-a Displays all connections and listening ports.

-o Displays the owning process ID associated with each connection.

-n Displays addresses and port numbers in numerical form.

Then kill the process by PID

/F — Specifies to forcefully terminate the process(es).

Note: You may need an extra permission (run from administrator) to kill some certain processes

Command:

Output:

Now cut the process ID, «10396», using the for command in Windows.

Command:

Output:

If you want to cut the 4th number of the value means «LISTENING» then command in Windows.

Command:

Output:

If you want to do this programmatically you can use some of the options given to you as follows in a PowerShell script:

However; be aware that the more accurate you can be the more precise your PID result will be. If you know which host the port is supposed to be on you can narrow it down a lot. netstat -aon | findstr «0.0.0.0:9999» will only return one application and most llikely the correct one. Only searching on the port number may cause you to return processes that only happens to have 9999 in it, like this:

The most likely candidate usually ends up first, but if the process has ended before you run your script you may end up with PID 12331 instead and killing the wrong process.

How do I kill the process currently using a port on localhost in Windows?

How can I remove the current process/application which is already assigned to a port?

For example: localhost:8080

21 Answers 21

Step 1:

Open up cmd.exe (note: you may need to run it as an administrator, but this isn’t always necessary), then run the below command:

Читайте также:  Ogg открыть windows media

with the port number you want, but keep the colon)

The area circled in red shows the PID (process identifier). Locate the PID of the process that’s using the port you want.

Step 2:

Next, run the following command:

(No colon this time)

Lastly, you can check whether the operation succeeded or not by re-running the command in «Step 1». If it was successful you shouldn’t see any more search results for that port number.

Step 1 (same is in accepted answer written by KavinduWije):

Change in Step 2 to:

Note: taskkill is not working in some git bash terminal

With Windows 10 default tools:

Open Windows PowerShell as Administrator

Find PID (ProcessID) for port 8080:

Kill the zombie process:

where «77777» is your PID

If you are using GitBash

( /F forcefully terminates the process)

I know that is really old question, but found pretty easy to remember, fast command to kill app that are using port.

Requirements: npm@5.2.0^ version

You can also read more about kill-port here: https://www.npmjs.com/package/kill-port

Result for Windows Command Prompt

In my case, 8080 is the port I want to kill
And 18264 is the PID listening on port 8080
So the task you have to kill is the PID for that particular port

If you already know the port number, it will probably suffice to send a software termination signal to the process (SIGTERM):

In Windows PowerShell version 1 or later to stop a process on port 3000 type:

Stop-Process (,(netstat -ano | findstr :3000).split() | foreach <$[$.length-1]>) -Force

As suggested by @morganpdx here`s a more PowerShell-ish, better version:

Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess -Force

For use in command line:

For use in bat-file:

For Windows users, you can use the CurrPorts tool to kill ports under usage easily:

I was running zookeeper on Windows and wasn’t able to stop ZooKeeper running at 2181 port using zookeeper-stop.sh, so tried this double slash «//» method to taskkill. It worked

If you can use PowerShell on Windows you just need :

If you’re using Windows Terminal then the killing process might be little less tedious. I’ve been using windows terminal and kill PID works fine for me to kill processes on the port as the new Windows Terminal supports certain bash commands. For example: kill 13300

So, the complete process will look like this-

  • Open Windows Terminal
  • Type the following command to show processes running on the port you’re looking to kill processes. netstat -ano | findstr :PORT
  • Type following to kill the process. kill PID

See when I typed the first command to list processes on the port it returned empty. That means all processes are killed now.

Update: kill is an alias for Stop-Process. Thanks, @FSCKur for letting us know.

Оцените статью