Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / Find Out Which Process is Listening on a Specific Port on Windows

April 5, 2023 PowerShellQuestions and AnswersWindows 10Windows 11Windows Server 2019

Find Out Which Process is Listening on a Specific Port on Windows

When starting a new service or app on Windows, you may find that the port you want to use is already occupied (listening) by another program (process). This article will show you how to find out which process is listening on a specific TCP or UDP port on Windows.

For example, you cannot run an IIS site on the default port 80 because the port is currently busy (if you are running multiple websites in IIS, you can run them on the same or different ports). So, how to find out which service or process that is listening on a port and kill it?

To get a complete list of the TCP and UDP ports that your computer is listening on, run the following command:

netstat -aon| find "LIST"

Or you can just enter the port number you are looking for:

netstat -aon | findstr ":80" | findstr "LISTENING"

Parameters used in the netstat command:

  • a – show network connections and open ports
  • o – show the Process Identifier (PID) for each connection
  • n – show addresses and port numbers in numeric format

The output of this command shows that TCP port 80 is being listened on (LISTENING state) by the process with PID 16124.

netstat - list open port on windows

You can identify the executable file of a process by its PID using Task Manager or the following command:

tasklist /FI "PID eq 16124"

find process name by PID

You can replace all of the above commands with a one-liner:

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

You can use a PowerShell one-line command to instantly get the name of the process listening on a specific port:

  • TCP port: Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess
  • UDP port: Get-Process -Id (Get-NetUDPEndpoint -LocalPort 53).OwningProcess

The tiny.exe process is listening on port 80 in our case.

powershell -find out which process is listening on a TCP or UDP port

Read the article about how to use PowerShell to view network connections in Windows.

Once you have the process identified, you can terminate it immediately by piping the results to the Stop-Process cmdlet:

Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess| Stop-Process

Check that port 80 is no longer in use:

Test-NetConnection localhost -port 80

how to check the port is not listening

To quickly find the path to the process executable in Windows, use the commands:

cd /
dir tiny.exe /s /p

Or you can use the built-in where command:

where /R C:\ tiny

In our case, we found that the executable tiny.exe (lightweight HTTP server) listening on port 80 is located in the directory c:\Temp\tinyweb\tinyweb-1-94.

find exe file in windows

You can also use the TCPView tool to view the list of processes and the TCP ports they listen to on Windows (https://learn.microsoft.com/en-us/sysinternals/downloads/tcpview).

TCPView - Find the Process Listening to Port on Windows

0 comment
0
Facebook Twitter Google + Pinterest
previous post
How to Use Plus Addressing in Microsoft 365 Exchange Online
next post
How to Increase Virtual Machine Disk Size in VMware

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Configuring Port Forwarding in Windows
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Configuring SFTP (SSH FTP) Server on Windows
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top