How Kill a process running on a port in Windows?

When working with Windows, multiple applications or services can compete for a single port at the same time. Only one can use a specific port at a given time. As a result, you may receive error messages saying that the selected port was already occupied by another application or service.

To fix issues related to port unavailability, it’s essential to find and stop the processes using that port. In such cases, we need to identify the unique process ID (PID) of the process listening on that port. The PID allows us to specifically target and terminate the interfering process, ensuring the port availability for other applications.

Through this guide, you will discover three common techniques and methods, including Command Prompt (CMD), Task Manager and PowerShell scripting to identify and kill unwanted processes in Windows VPS and client environment. Now, Let’s take control of your system’s ports and detail each method

How to kill a process on a port using Windows CMD?

In Windows OS( server/client ), the command prompt is regarded as a reliable command-line interpreter, providing users with precise control over a variety of system components, including processes. Here, you can use several commands to manage and control your system.

For example, “tasklist” is one of the primary commands that shows the open and running ports on Windows and the associated PIDs. CMD also provides another essential command for terminating processes, which is called “taskkill”. Taskkill allows users to end processes based on their PID or process name.

Follow our step-by-step instructions to find and stop a process running on a specific Windows port just by using Command Prompt.

step 1: Open Command Prompt: As a first move, press the Windows + R key and enter cmd in the search box.

step 2: Identify the PID: Type the “tasklist” command and press Enter to find the port number and associated PID you want to free up.

tasklist

step 3: Kill the Process: In this step, the taskkill command followed by the PID and F flag, forces the process to terminate. Just type the below command and press enter:

taskkill /PID <PID>

taskkill /PID <name>

taskkill /PID <PID>

Note: Remember to replace “<PID>” with the actual process ID and “<name>” with the process name.

step 4: Confirm Termination: Re-run the “tasklist” command to verify that the operation was successful. If the port is not listed among the listening ports, you can confirm that the process has been terminated.

How to kill a process on a port using Task Manager?

If you prefer a more visual approach to easily terminate processes listening on a specific port, Task Manager is a sure bet. It offers a user-friendly graphical interface to view and control running processes in Windows.

Stay on track to figure out how to view PID in task manager and end the process using a specified port.

step 1: Open Task Manager: At the bottom of your screen, right-click on the taskbar and select Task Manager from the menu. Or press the “Ctrl + Shift + Esc” keys to run Task Manager.

Task Manager

step 2: Identify the Process: Once Task Manager is open, move to the “Details” tab from the top bar. Then find the process associated with the port you want to stop. Check the PID column to easily identify the process you are looking for.

Details

step 3: End the Process: On the Name (For example Anydesk) column “click right” on the process and tap on the “End”.

2024 04 03 15 05 42 Task Manager

Now, confirm the termination and get it done.

2024 04 03 15 06 09 Task Manager

step 4: Verify the Termination: Check the active connections list to ensure that the process is no longer running. If the process disappears, you can verify it was successfully stopped.

How to kill a process on a port using Power shell?

PowerShell is an ideal tool for advanced users and automation tasks, which has a wide set of commands and utilities to efficiently manage processes.

It offers powerful scripting capabilities that allows users to locate and terminate processes operating on a specific port using simple commands. Follow these steps:

step 1: Open PowerShell: Get access to the PowerShell script either by searching for it in the Windows search bar or by pressing the Win + X button and choosing ‘Windows PowerShell (Admin)’ to run it with administrator privileges.

PowerShell

step 2: Identify the PID of the Port: Enter the following command to look for the process ID associated with the desired port:

Get-Process

Get-Process

By running the command, you will be shown a long list of processes running on the Windows port. You can kill a process running on a port in Windows by using the name or ID number.

step 3: Stop the Process: After the PID identification, kill the process by entering the subsequent command:

Stop-Process -Id <ID Number>

Stop-Process -name <Name>

Note: Use the actual process ID or name instead of <PID>, <Name>.

Common Errors in Using PowerShell to Kill Windows Process

1) Invalid Syntax Error: This will come up when the command is misspelled, missing required parameters, or includes an incorrect format.
2) Execution Policy Restriction: By default, PowerShell execution policies prevent most scripts or commands from running. Set the execution policy to allow scripts using the command Set-ExecutionPolicy RemoteSigned.

Each of the above mentioned methods offers its own advantages and suitability for different users and scenarios. And all are effective in terminating processes running on a port within the Windows server and Windows Client environment.

Conclusion

To sum up, we have discussed three major techniques for terminating a process running on a port in Windows. This guide has covered Command Prompt, Task Manager and PowerShell for efficiently terminating processes running on a certain port in the Windows operating system. Each of these tools will help you manage system resources more efficiently, resolve port-related issues and keep your Windows environment running smoothly.

To do the above, you need to make sure that the desired port is open, if the desired port is closed, you must open the port from your Windows firewall to be able to use it.

Related posts

How to open port on Windows VPS?

Reconfiguring Mikrotik VPS’s port-number

How To Change Default Port (3389) In RDP Server?


author image

The Author Robert Smite

Hello! I'm Robert, specializing in virtual servers and cloud technology. With expertise in managing and optimizing virtual servers, my focus is on delivering understandable and practical content in this field. My goal is to enhance knowledge and assist individuals in selecting the best virtual services for their needs.

More from Robert Smite

Post Your Comment

Your email address will not be published. Required fields are marked *