I had process blocking a port that I needed to use for a docker container and it took forever to resolve. In my case it was PID 4 using port 80 too.
Thought I'd summarise all of the potential issues and solutions I found while trying to resolve - hopefully useful for someone else in future.
For anyone new coming to this, you can investigate the service using the respective port by following these steps to try to figure out what it is.
In Powershell we can check for what process is using this port:
netstat -aon | findStr /i "LISTENING" | findStr ":80"
To check what process this is:
tasklist /FI "PID eq 4"
Another way to get the process ID using the port:
Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess
Check whether the port has ben reserved for use by another process with:
netsh int ipv4 show excludedportrange protocol=tcp
Also look in Resource Monitor to see if that gives you any more clues.
I tried all of the suggestions I found here and in other posts:
None of these worked to free up the port.
In the end I decided to check for any recent Windows Updates that could have caused it - there was nothing new in the last two weeks.
But when I check for recently installed applications (using Bulk Crap Uninstaller - it's excellent!) I noticed two 'apps' installed yesterday which I definitely didn't manually install so I think they somehow came through Win Update or an auto app update:
- Microsoft Edge Webview 2 Runtime
- Web Components
After uninstalling these, I had access to port 80 again!
To make sure it wouldn't happen again, I reserved the port for my own use:
netsh int ipv4 add excludedportrange protocol=tcp startport=80 numberofports=1
telnet 127.0.0.1 80
and then past that line in and press enter twice. If you're running Windows 7, you need to install telnet client from "add and remove Windows features" first.netsh http show servicestate
and look at registered URLs or Logging information.