How to Check for Ports in Use in Windows 10
At any one time, there’s a whole bunch of information being sent between your Windows 10 PC and the endless void of the Internet. This is done using a process whereby network-dependent processes seek out TCP and UDP ports, which they use to communicate with the Internet. First, your data gets sent to remote ports at the destination or website your processes are trying to connect to, then it gets received at local ports back on your PC.
Most of the time, Windows 10 knows how to manage ports and ensure that traffic is being directed through the right ports so that those processes can connect with what they need to. But sometimes two processes may be assigned to one port, or maybe you just want to get a better picture of your network traffic and what’s going in and out.
That’s why wrote this guide that shows you how to get an overview of your ports and see which applications are using which ports.
Use Nirsoft CurrPorts
NirSoft is one of the best indie software developers, giving us great utilities, like PassView and WirelessKeyView. While some people will prefer checking their ports without installing third-party software (in which case, scroll down to the CMD method), CurrPorts is easily the fastest and most convenient way to view your ports.
Once you’ve installed CurrPorts, just open it to see a list of all your ports currently in use. If you’re looking for local ports in use, just click the “Local Port” column at the top to order the list by port number (handy if you’re looking for a specific one). You can do the same thing with remote ports, too.
If you want to really find specific ports, click the “Advanced Filters” icon at the top and enter your string in the format they suggest. It should look something like the below image.
Hit OK when you’re ready, and the list will filter down to your queries.
Command Prompt Method
The integrated – though not necessarily the simplest – way to check open ports is to use the trusty command prompt.
Click the Start button, type cmd , then right-click “Command Prompt” when it shows up in the search results. Click “Run as administrator.”
Once you’re in the elevated command prompt, enter the following command:
This will steadily bring up a list of ports that is probably quite long, along with the Windows processes that are using them. (You can press Ctrl + A , then Ctrl + C to copy all information to the clipboard.) On the average PC, there will be two main local IP addresses that contain ports on your PC.
The first, in our case, is “127.0.0.1.” This IP address is otherwise known as “localhost” or a “loopback address,” and any process listening to ports here is communicating internally on your local network without using any network interface. The actual port is the number you see after the colon. (See image below.)
The bulk of your processes will probably be listening to ports prefixed with “192.168.xxx.xxx,” which is your IP address. This means the processes you see listed here are listening for communications from remote Internet locations (such as websites). Again, the port number is the number after the colon.
TCPView
If you don’t mind installing a third-party app and want to have more control over what’s going on with all your ports, you can use a lightweight app called TCPView. This immediately brings up a list of processes and their associated ports.
What make this better than the command prompt is that you can actively see the ports opening, closing and sending packets. Just look for the green, red and yellow highlights. You can also reorder the list by clicking the column headings, making it easier to find the process you want or two separate processes vying for the same port.
If you do find a process or connection you want to close, just right-click that process. You can then select “End process,” which is exactly the same function as the one in Windows task manager. Or you can click “Close Connection” to leave the process open but stop it from listening on a given port.
If you’re having some trouble in Windows 10, then see whether a Windows update may be causing it. We also have a handy guide for managing the health of your hard drive in Windows 10.
Related:
Content Manager at Make Tech Easier. Enjoys Android, Windows, and tinkering with retro console emulation to breaking point.
How do I get a list of available serial ports in Win32?
I have some legacy code that provides a list of the available COM ports on the PC by calling the EnumPorts() function and then filtering for the port names that start with «COM».
For testing purposes it would be very useful if I could use this code with something like com0com, which provides pairs of virtual COM ports looped together as a null-modem.
However the com0com ports are not found by the EnumPorts() function (even without filtering for «COM»). HyperTerminal and SysInternals PortMon can both see them, so I’m sure it is installed correctly.
So is there some other Win32 function that provides a definitive list of available serial ports?
5 Answers 5
The EnumSerialPorts v1.20 suggested by Nick D uses nine different methods to list the serial ports! We’re certainly not short on choice, though the results seem to vary.
To save others the trouble, I’ll list them here and indicate their success in finding the com0com ports on my PC (XP Pro SP2):
CreateFile(«COM» + 1->255) as suggested by Wael Dalloul
✔ Found com0com ports, took 234ms.
QueryDosDevice()
✔ Found com0com ports, took 0ms.
GetDefaultCommConfig(«COM» + 1->255)
✔ Found com0com ports, took 235ms.
«SetupAPI1» using calls to SETUPAPI.DLL
✔ Found com0com ports, also reported «friendly names», took 15ms.
«SetupAPI2» using calls to SETUPAPI.DLL
✘ Did not find com0com ports, reported «friendly names», took 32ms.
EnumPorts()
✘ Reported some non-COM ports, did not find com0com ports, took 15ms.
Using WMI calls
✔ Found com0com ports, also reported «friendly names», took 47ms.
COM Database using calls to MSPORTS.DLL
✔/✘ Reported some non-COM ports, found com0com ports, took 16ms.
Iterate over registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
✔ Found com0com ports, took 0ms. This is apparently what SysInternals PortMon uses.
Based on those results I think the WMI method probably suits my requirements best as it is relatively fast and as a bonus it also gives the friendly names (e.g. «Communications Port (COM1)», «com0com — serial port emulator»).
It appears that it’s not a simple task.
you can make loop for example from 1 to 50 and try to open each port. If the port is available, the open will work. If the port is in use, you’ll get a sharing error. If the port is not installed, you’ll get a file not found error.
to open the port use CreateFile API:
then check the result.
In my case, I need both the full names and COM port addresses. I have physical serial ports, USB serial ports, and com0com virtual serial ports.
Like the accepted answer suggests, I use WMI calls. SELECT * FROM Win32_PnPEntity find all devices. It returns physical devices like this, and address can be parsed from Caption :
However, for com0com ports Caption is like this (no address):
SELECT * FROM Win32_SerialPort returns addresses ( DeviceID ), as well as full names ( Name ). However, it only finds physical serial ports and com0com ports, not USB serial ports.
So in the end, I need two WMI calls: SELECT * FROM Win32_SerialPort (address is DeviceID ) and SELECT * FROM Win32_PnPEntity WHERE Name LIKE ‘%(COM%’ (address can be parsed from Caption ). I have narrowed down the Win32_PnPEntity call, because it only needs to find devices that were not found in the first call.
This C++ code can be used to find all serial ports:
Windows get port list
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Asked by:
Question
The following code has worked on a number of Windows 10 machines, but I have just found one where it does not work because the registry of this particular copy of windows 10 does not have a SERIALCOMM folder.
The system COM ports must be listed some where so, if not under SERIALCOMM, then where?
All replies
Hi Gregary Boyles,
thanks for posting here.
According to this document, the SERIALCOMM subkey stores data about serial ports on the computer. This subkey is part of the HARDWARE key, and it is recreated each time the system starts.
And I test in my Win10, it has this folder in HKLM\HARDWARE\DEVICEMAP\SERIALCOMM.
Hope this could be help of you.
Best Regards,
Sera Yu
MSDN Community Support
Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
I have done some research on a laptop here that also did not have that key initially. Apparently that key is specifically associated with bluetooth devices and is not ‘installed’ until you pair with the first bluetooth device.
From then on the key remains in the registry but it only contains any keys for as long as you are paired with a bluetooth device.
Irritatingly the native windows bluetooth software at first fills in two keys — one for out put and one for input. However, through Visual Studio ::CreateFile(. ), only the input COM port is functional for both input and output. The output COM port apparently serves no useful purpose.
And at some point windows 10 on the laptop stopped creating two separate ports for my bluetooth device. Only one COM port is listed for my device when I pair with it now.
What can I say but that Windows is one big complicated mess!