How to check which Process is holding TCP Port - Using netstat command

Introduction

After changing to a new port, it is important to verify whether the old port is still in use. This helps prevent conflicts with other applications and ensures the new configuration is working correctly.

In this article, you will learn how to check if a specific TCP port is in use on Windows and how to identify which process is holding that port using built-in system tools.

Steps

Checking if a port is in use

To determine whether a port is currently being used, follow these steps:

  1. Open the Command Prompt.

  2. Run the following command (replace the port number with the one you want to check):

    netstat -ano | findstr :50433
    
  3. Review the output:

Identifying which process is using the port

If the port is in use, you can identify the process holding it by checking the PID (Process ID).

  1. Run the command to search for the port and note the PID (Process ID), which is the last column in the console output. This PID corresponds to the process that is holding the port.
    netstat -ano | findstr :5000

  2. Open the Task Manager.

  3. Navigate to the Details tab.

  4. Sort the list by the PID column and locate the PID to match it with the console output. This will identify the process that is holding the port.

  5. To release the port, you need to terminate this process. If possible, avoid killing it abruptly; instead, try to exit it gracefully.