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
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.
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>
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.
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.
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.
step 3: End the Process: On the Name (For example Anydesk) column “click right” on the process and tap on the “End”.
Now, confirm the termination and get it done.
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.
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.
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
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>.
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.
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.
How to open port on Windows VPS?