How can you find out which process is listening on

2018-12-31 04:17发布

How can you find out which process is listening on a port on Windows?

26条回答
有味是清欢
2楼-- · 2018-12-31 04:46

powershell

Get-Process -Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess

cmd

 C:\> netstat -a -b

(add -n to stop it trying to resolve hostnames, which will make it a lot faster)

Note Dane's recommendation for TCPView. Looks very useful!

-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楼-- · 2018-12-31 04:46

To find out which specific process(PID) is using which port:

netstat -anon | findstr 1234

Where 1234 is the PID of your process. [Go to Task Manager -> Services/Processes tab to find out the PID of your application]

查看更多
萌妹纸的霸气范
4楼-- · 2018-12-31 04:47

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.

查看更多
浅入江南
5楼-- · 2018-12-31 04:48

netstat -ao and netstat -ab tell you the application, but if you're not admin you'll get "The requested operation requires elevation".

It's not ideal, but if you use sysinternals Process Explorer you can go to specific processes' properties and look at the TCP tab to see if they're using the port you're interested in. Bit of a needle and haystack thing, but maybe it'll help someone....

查看更多
怪性笑人.
6楼-- · 2018-12-31 04:49
  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.

查看更多
若你有天会懂
7楼-- · 2018-12-31 04:49

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)

查看更多
登录 后发表回答