- Information Security Squad
- 🔍 Какой процесс прослушивает порт на Windows?
- Как узнать, какой процесс прослушивает определенный порт в операционной системе Windows?
- 1. Использование командной строки
- 2. Использование PowerShell Get-Process
- Заключение
- How do I kill the process currently using a port on localhost in Windows?
- 21 Answers 21
- Find the PID of a process that uses a port on Windows
- 7 Answers 7
- How do I determine which process is using a serial port?
- 3 Answers 3
- How to determine which program uses or blocks specific Transmission Control Protocol ports in Windows Server 2003
- Summary
- How to match the process ID to a program
- How to obtain additional information about the Netstat.exe utility
Information Security Squad
stay tune stay secure
- Home
- 2020
- Октябрь
- 29
- 🔍 Какой процесс прослушивает порт на Windows?
🔍 Какой процесс прослушивает порт на Windows?
Как узнать, какой процесс прослушивает определенный порт в операционной системе Windows?
Эта статья поможет вам найти имя процесса, прослушивающего определенный порт в системе Windows.
Иногда при установке приложения вы могли столкнуться с проблемой типа «port in use».
Вы можете выбрать один из двух способов, указанных ниже.
Первый метод использует netstat, чтобы найти pid процесса, прослушивающего определенный порт, затем используется список задач, чтобы найти имя процесса по pid.
1. Использование командной строки
Используйте следующую команду, чтобы узнать идентификатор процесса (pid), прослушивающий порт 433 .
Вы можете изменить это значение для поиска другого порта.
В последнем столбце выходных данных отображается идентификатор процесса.
Приведенный выше вывод показывает, что pid равен 2189 и 4620 для процессов, прослушивающих порт 443.
Используйте этот идентификатор процесса с командой списка задач, чтобы найти имя процесса.
В результатах вы увидите имя процесса, как показано на скриншоте выше.
2. Использование PowerShell Get-Process
Второй метод использует команду PowerShell для определения процесса, запущенного на определенном порту в Windows.
Запустите терминал PowerShell и выполните следующую команду, чтобы найти имя процесса, работающего на порту 443.
Вы можете изменить номер порта, чтобы проверить наличие других портов.
В результатах вы увидите имя процесса, как показано на скриншоте выше.
Заключение
В этом руководстве вы узнали два метода поиска имени процесса, прослушивающего определенный порт в системе Windows.
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:
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.
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 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.
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.
How to determine which program uses or blocks specific Transmission Control Protocol ports in Windows Server 2003
This step-by-step article discusses how to determine which program uses or blocks specific Transmission Control Protocol (TCP) ports.
For a Microsoft Windows XP version of this article, see 281336.
Original product version: В Windows Server 2003
Original KB number: В 323352
Summary
The Netstat.exe utility has a new switch, the -o switch, that can display the process identifier (ID) that is associated with each connection. This information can be used to determine which process (program) listens on a particular port. For example, the netstat -ano command can produce the following output:
If you use Task Manager, you can match the process ID that is listed to a process name (program). With this feature, you can find the specific port that a program currently uses. Because a program already uses this specific port, another program is prevented from using that same port.
How to match the process ID to a program
To match the process ID to a program, follow these steps:
- Press Ctrl+Alt+Delete, and then click Task Manager.
- Click the Processes tab.
- If you don’t have a PID column, click View >Select Columns, and then click to select the PID (Process Identifier) check box.
- Click the column header that is labeled «PID» to sort the process by PIDs. You should be able to easily find the process ID and match it to the program that is listed in Task Manager.
How to obtain additional information about the Netstat.exe utility
To obtain additional information about the Netstat.exe utility, follow these steps:
- Click Start >Run.
- In the Open box, type cmd, and then click OK.
- At a command prompt, typenetstat /?.
—>