Вопрос: Как узнать, какой процесс прослушивает порт в Windows?


Как узнать, какой процесс прослушивает порт в Windows?


1437


источник


Ответы:


C:\> netstat -a -b

(Добавить -n чтобы остановить его, пытаясь разрешить имена хостов, что сделает его намного быстрее)

Примечание. Рекомендация Датча TCPView , Выглядит очень полезно!

-a Отображает все подключения и прослушивающие порты.

-b Отображает исполняемый файл, участвующий в создании каждого соединения или         порт прослушивания. В некоторых случаях известный хост исполняемых файлов         несколько независимых компонентов, и в этих случаях         последовательность компонентов, участвующих в создании соединения         или порт прослушивания. В этом случае исполняемый файл         имя находится в [] внизу, сверху - компонент, который он назвал,         и т. д. до тех пор, пока не будет достигнут TCP / IP. Обратите внимание, что этот параметр         может занять много времени и не удастся, если у вас недостаточно         разрешения.

-n Отображает адреса и номера портов в цифровой форме.

Отображает идентификатор процесса владения, связанный с каждым соединением.


1613



Для Windows есть собственный графический интерфейс:

  • Начало >> Все программы >> Аксессуары >> Системные инструменты >> Монитор ресурсов

или Бег resmon.exe, или из Диспетчер задач вкладка производительности

enter image description here


1561



использование TCPView если вам нужен графический интерфейс. Это старое приложение Sysinternals, которое Microsoft выкупила.


173



netstat -aon | find /i "listening"

122



You can get more information if you run the following command:

netstat -aon |find /i "listening" |find "port"

using the 'Find' command allows you to filter the results. find /i "listening" will display only ports that are 'Listening'. Note, you need the /i to ignore Case otherwise you would type find "LISTENING". |find "port" will limit the results to only those containing the specific port number. Note, on this it will also filter in results that have the port number anywhere in the response string.


60



  1. Open a command prompt window (as Administrator) From "Start\Search box" Enter "cmd" then right-click on "cmd.exe" and select "Run as Administrator"

  2. Enter the following text then hit Enter.

    netstat -abno

    -a Displays all connections and listening ports.

    -b Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.

    -n Displays addresses and port numbers in numerical form.

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

  3. Find the Port that you are listening on under "Local Address"

  4. Look at the process name directly under that.

NOTE: To find the process under Task Manager

  1. Note the PID (process identifier) next to the port you are looking at.

  2. Open Windows Task Manager.

  3. Select the Processes tab.

  4. Look for the PID you noted when you did the netstat in step 1.

    • If you don’t see a PID column, click on View / Select Columns. Select PID.

    • Make sure “Show processes from all users” is selected.


56



Get PID and Image Name

Use only one command:

for /f "tokens=5" %a in ('netstat -aon ^| findstr 9000') do tasklist /FI "PID eq %a"

where 9000 should be replaced by your port number.

The output will contain something like this:

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
java.exe                      5312 Services                   0    130,768 K

Explanation:

  • it iterates through every line from the output of the following command:

    netstat -aon | findstr 9000
    
  • from every line, the PID (%a - the name is not important here) is extracted (PID is the 5th element in that line) and passed to the following command

    tasklist /FI "PID eq 5312"
    

If you want to skip the header and the return of the command prompt, you can use:

echo off & (for /f "tokens=5" %a in ('netstat -aon ^| findstr 9000') do tasklist /NH /FI "PID eq %a") & echo on

Output:

java.exe                      5312 Services                   0    130,768 K

39



First we find process id of that particular task which we need to eliminate in order to get port free

type
netstat -n -a -o

After executing this command in windows command line prompt(cmd) select the pid which i think the last column suppose this is 3312

Now type

taskkill /F /PID 3312

You can now cross check by typing netstat command.

NOTE: sometimes windows doesn`t allow you to run this command directly on CMD so first you need to go with this steps from start-> command prompt (right click on command prompt, and run as administrator)


34



If you want to find the process name based on port number.
I found this one with a bit of surfing through multiple sites.
Open command prompt as administrator.
1. Find the pid of the process running in the port number. Ex-8080
      netstat -abon | findStr "8080"
2. Find the process Name by pid
      tasklist /fi "pid eq 13556"

Finding process name from port num








21



It is very simple to get the port number from pid in windows.

The following are the steps:

1) Go to run --> type cmd --> press enter.

2) write the following command...

netstat -aon | findstr [port number]

(Note: Don't include square brackets.)

3) press enter...

4) Then cmd will give you the detail of the service running on that port alongwith pid.

5) Open task manager and hit the service tab and match the pid with that of the cmd and that's it.


20



To get a list of all the owning process ID associated with each connection:

netstat -ao |find /i "listening"

If want to kill any process have the id and use this command, so that port become free

Taskkill /F /IM pidof a process

17