How do you kill the port on Windows?

How do you set a port free that is assigned to a particular process or application? This tutorial shows how to kill the port in the Windows operating system.

Issue

I got into trouble with my Spring Boot application on my development machine. The application port occupancy prevented my local Spring development environment from running. By default, Spring uses port 8443. So, I needed to make the port free to run my application without needing to rewrite the port number in the application config file.

Solution

Here is a simple solution on how to set the occupied port free on Windows OS:

Step 1

You must run the Windows Command Line as an Administrator or Git Bash. Then, run the command below with the port number in the port number placeholder.

netstat -ano | findstr :MY_PORT_NUMBER

The number on the right side (PID – process identifier) is the number of processes currently using the port.

Step 2

For this, you can use only the Windows Command Line. First, you need to kill the process using the port so the port can be set free. Type the following command with process PID to the command line:

taskkill /PID YOUR_PID_NUMBER /F

Prefix /F, in this case, means forcefully terminates the process.

If everything went smoothly, you should get the following message:

SUCCESS: The process with PID YOUR_PID_NUMBER has been terminated.

In the end, rerun the first command to check whether the process is on or not. If you get an empty line, the process successfully ends, and the required port is free.

Conclusion

This article shows how to kill the Windows operating system port quickly.

Did you find releasing ports easy? Do you have your trick, or do you know another way how to kill specific port on the Windows operating system? Let us know in the comments below. We would like to hear your ideas and stories.

This entry was posted in Solutions and tagged , . Bookmark the permalink.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.