Identifying which program has occupied your port number – Windows Edition

What happened

Often, during the development or startup of a program, many of us encounter the message “Port XX is already in use.

So, what’s the usual course of action? Do people promptly adjust the settings to assign a different port number, or do they first investigate which program currently occupies that port?

Today, I’ll discuss the method of checking for a specific port within the CMD (Command Prompt).

netstat

Netstat” is a command in Windows CMD used to query the current network status, including connection status at the Transmission Control Protocol (TCP) layer, routing tables, network interface status, and statistical information about network protocols.

Using “netstat -h” will display all available options.

The command we’ll be using today is:

netstat -ano | find "****"

Replace “****” with the port number you want to query.

Now, let’s take an example. I have locally launched a Flask program using Python, occupying port 5000.

The result you’ll obtain would look something like this:

The last number you see is the PID (Process Identifier), which can be understood as a unique number assigned by the system. Each number corresponds to a specific program.

Now, the process isn’t finished yet. Open the Task Manager and in the search box, look up the PID you just identified.

Now, you can see that “python.exe” is currently using that PID. Depending on your needs, you can decide whether to force terminate the process or take any other necessary actions.


Conclusion

It’s quite a practical article, isn’t it? This way, you don’t have to go through programs one by one to exclude them.

You can easily use CMD along with Task Manager to find out which program is currently using a specific port.

💔 The entire article was written independently. Feel free to quote or reference, but please avoid copying the entire content.

🧡You can support our team by sharing the post or clicking some ads, Thanks a lot

If you have any problem about this post, please feel free to ask~

Some Random notes

Leave a Reply

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