PID exists in netstat but does not exist in task manager

WindowsServiceNetwork Programming

Windows Problem Overview


I have discovered a running process with PID 26376 listening on port 9001 and 9002 as when I try to run my program(as a service) which binds to that port it fails.

But when I try to kill it using taskkill /PID it says that the process 26376 is not found. Similarly when I try to find the process in task manager with "Show processes from all users" selected, I couldn't find it anywhere.

Can anyone explain this? Is it a defunct zombie process? I suspect that the process listening on that port is a previous instance of my program running but what could have caused this?

EDIT: Sysinternals TCPView shows the process as non-existent. Sysinternals Process Explorer does not show the process. Tasklist does not show the process.

Windows Solutions


Solution 1 - Windows

You don't need Task Manager for tracking this. Just run netstat -b which will display the exe associated with the PID..

Solution 2 - Windows

Well, in my case killing all the conhost.exe instances owned by the same user as the initial process released the port.

Solution 3 - Windows

(improved from @mfck's answer)

  1. kill all processes named cmd.exe
  2. kill all processes named conhost.exe

Solution 4 - Windows

Another option is to bounce the NIC associated with the connection. Be careful if you are doing this over RDP, you'll want to script it so the NIC will come back online or you'll lock yourself out and will need console access.

This link explains how to do it with CMD and powershell:

https://www.windowscentral.com/how-enable-or-disable-wi-fi-and-ethernet-network-adapters-windows-10

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshawnView Question on Stackoverflow
Solution 1 - WindowsParth ModyView Answer on Stackoverflow
Solution 2 - WindowsmfckView Answer on Stackoverflow
Solution 3 - Windowsch271828nView Answer on Stackoverflow
Solution 4 - WindowsBlaise BrignacView Answer on Stackoverflow