How to find which program is using port 80 in Windows?

This question already has an answer here:

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

  • Start->Accessories right click on "Command prompt", in menu click "Run as Administrator" (on Windows XP you can just run it as usual), run netstat -anb then look through output for your program.

    BTW, Skype by default tries to use ports 80 and 443 for incoming connections.

    You can also run netstat -anb >%USERPROFILE%ports.txt followed by start %USERPROFILE%ports.txt to open port and process list in a text editor, where you can search for information you want.

    You can also use powershell to parse netstat output and present it in a better way (or process any way you want):

    $proc = @{};
    Get-Process | ForEach-Object { $proc.Add($_.Id, $_) };
    netstat -aon | Select-String "s*([^s]+)s+([^s]+):([^s]+)s+([^s]+):([^s]+)s+([^s]+)?s+([^s]+)" | ForEach-Object {
        $g = $_.Matches[0].Groups;
        New-Object PSObject | 
            Add-Member @{ Protocol =           $g[1].Value  } -PassThru |
            Add-Member @{ LocalAddress =       $g[2].Value  } -PassThru |
            Add-Member @{ LocalPort =     [int]$g[3].Value  } -PassThru |
            Add-Member @{ RemoteAddress =      $g[4].Value  } -PassThru |
            Add-Member @{ RemotePort =         $g[5].Value  } -PassThru |
            Add-Member @{ State =              $g[6].Value  } -PassThru |
            Add-Member @{ PID =           [int]$g[7].Value  } -PassThru |
            Add-Member @{ Process = $proc[[int]$g[7].Value] } -PassThru;
    #} | Format-Table Protocol,LocalAddress,LocalPort,RemoteAddress,RemotePort,State -GroupBy @{Name='Process';Expression={$p=$_.Process;@{$True=$p.ProcessName; $False=$p.MainModule.FileName}[$p.MainModule -eq $Null] + ' PID: ' + $p.Id}} -AutoSize
    } | Sort-Object PID | Out-GridView
    

    Also it does not require elevation to run.


    type in command:

    netstat -aon | findstr :80 netstat -aon | findstr :80 .

    it will show you all processes that use port 80. notice the pid in the right colum.

    if you would like to free the port, go to task manager, sort by pid and close those processes.


    If you want to be really fancy, download TCPView from sysinternals

    TCPView is a Windows program that will show you detailed listings of all TCP and UDP endpoints on your system, including the local and remote addresses and state of TCP connections. On Windows Server 2008, Vista, and XP, TCPView also reports the name of the process that owns the endpoint. TCPView provides a more informative and conveniently presented subset of the Netstat program that ships with Windows.

    链接地址: http://www.djcxy.com/p/30284.html

    上一篇: 你怎么能在批处理文件中回显一个换行符?

    下一篇: 如何在Windows中查找使用端口80的程序?