How to Kill Process on Port?

Ports are used by applications to send and receive data from and to their servers. Every application uses a specific set of ports to communicate and these ports are either automatically or manually opened when the application is installed. In this article, we will discuss the methods to terminate a process related to a port. Since all applications use a specific port, we can ask the operating system to terminate the process that is using a specific port.

How to Kill a Process on Port

How to Kill Process on Port?

Applications that are communicating on a specific port can easily be terminated by instructing the computer to do so. This process, however, differs on operating systems and requires administrative privileges. Also, make sure that there isn’t any other application that is using the port. Below the method to kill a process from its port number is listed below, since the method differs on operating systems, we have listed the methods for some of the most popular ones.

Kill Process on Port in Mac and Linux

  1. Open the terminal and make sure you are signed in as the root user.
    opening the terminal
  2. List the processes that are listening on a specific port by typing in the following command and executing it.
    lsof -i:(port number)
  3. In order to terminate any process that is using the port number to communicate, type in the following command and execute it.
    kill $(lsof -t -i:"Port Number")
  4. The above command might not work on high privilege applications, therefore, execute the following command to immediately terminate any process communicating at a specific port.
    kill -9 $(lsof -t -i:"Port Number")
  5. This command will immediately terminate any process communicating through the specified port number.

Kill Process on Port in Windows

  1. Press “Windows” + “R” to open Run prompt.
  2. Type in “cmd” and press “Shift” + “Ctrl” + “Enter” to open in administrative mode.
    Typing cmd in the Run Prompt and pressing “Shift”+ “Ctrl” + “Enter”
  3. Type in the following command to list the process communicating on a specific port.
    netstat -ano | findstr :<yourPortNumber>
    Typing in the command
  4. This will list the process running on a specific port, note the “PID” for the program.
  5. In order to kill all the processes using the specific port, type in the following command and press “Enter” to execute it.
    taskkill /PID <typeyourPIDhere> /F
  6. This will immediately terminate the program.
ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.