Every time you plug in a COM or USB device to your computer, the Plug-n-Play service on Windows creates a virtual COM port and assigns it to a device. COM is the name of the serial port interface and can refer to both physical ports (such as RS-232), and emulated ports created by USB (USB-to-UART, USB-to-COM), and Bluetooth adapters.
Every COM port has its number from 1 to 255. Also, each port is assigned exclusively for one device and remains occupied (Windows shows it as “in use”) even if the device itself is not plugged in anymore. This ensures that there are no conflicts when two or more COM devices are connected simultaneously.
Most of the time this is not a big deal or problem unless a user tries to run some legacy software that has trouble working with COM-ports higher than 9. For example, such an app may work well with COM1 to 9, but fail if there are no free COM ports below COM10. Another issue may appear when some specific devices take too many ports. If the device is connected to a different physical USB port, a new COM port number will be assigned to it. For example, some adapters may reserve up to 30 or even more COM ports. In such a scenario, you are forced to delete COM ports in use in Windows or reassign a used COM port to a different device. In this article, we will show you how to do this.
Clear COM Ports in Use
There are different methods on how to delete COM ports in use. Luckily, there are different apps with a decent UI you can use to work with COM ports on your computer. Windows stores COM ports assignments in the registry value of the ComDB parameter under reg key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter. We will show how to use the Registry Editor to clear or reassign COM ports, but first, let us focus on more user-friendly ways to delete COM ports in use.
Caution. Before deleting COM ports in use, make sure to create a system restore point. Having a backup gives you a path back in case something goes wrong. The system restore point will help you to go back quickly and restore your system functionality.
How to Manually Reassign COM Ports Using the Device Manager?
First, let us go through the simplest method. You can quickly reassign the COM port using the built-in Device Manager. This will work only if you have a free COM port you need to reassign. For example, Windows assigned COM24 for your device, but you need COM9 or any other COM port.
- On your keyboard, press Win + R and enter the devmgmt.msc command;
- Locate the Ports section and expand it;
- Find the device you need to reassign the COM port and right-click on it. Select Properties;
- In a new window, go to the Port Settings tab and press the Advanced button;
- Select a new COM port number from the COM Port Number drop-down list at the bottom of a new window.
- A warning may appear stating that the selected COM port number is already in use. You can ignore this warning by selecting “Yes” and this should not cause any issues.
This will work only if the COM port you need to use is free. If Windows says the port you need is in use, these instructions won’t work. Do not worry, though. You can manually delete the used COM port and reassign it for a new device.
Note. Check our tutorial on how to fix User profile cannot be loaded in Windows.
Delete COM Ports in Use on Windows
- By default, disconnected and unavailable devices are not shown in Device Manager. To display them, open the Device Manager (Win + R > devmgmt.msc > OK), and select View > Show Hidden Devices from the menu;
- The next step is to display all COM ports in use. Locate the Ports (COM & LPT) section. Do notice that every device shows which port it occupies.
Tip. Disconnected devices have pale (transparent) icons and devices you have plugged in to show a regular icon. Do not uninstall the devices currently connected; - Find the port you need to free and right-click on it. Select Uninstall. If some specific device occupies several ports simultaneously, you need to remove them altogether;
- DO NOT check the option “Delete the driver software for this device”;
- Repeat these steps until all grayed-out COM ports are removed;
- After this, Windows will free a port number, so you can assign it to the device you need. Go back to the Reassign COM ports using the Device Manager section and follow it to reassign the port you just made free.
Note. On Windows, COM numbers increase because the reservation is not removed when the COM port device is uninstalled. Starting with Windows 10 build 1903, Microsoft fixed this behavior. Now when a device is uninstalled from Device Manager, the COM port number reservation is removed.
There is another way how to check which COM ports are currently in use. Although there is nothing wrong with using the Device Manager, you can check the list using it. Open an elevated PowerShell console and paste the following command:
Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description
How to Check Which Program Uses the Serial (COM) Port?
Many programs or devices require exclusive access to the serial port. Communication via a serial COM port means that only one application can control a serial device at a time. If the COM port is occupied by another application, then errors in the operation of various programs or drivers may occur due to a serial COM port locking conflict.
Note. Learn how to SSH into Windows.
You can figure out which particular Windows process is using the COM port via the Process Explorer tool. This guide has been tested on Windows 11, but it applies to all previous versions of Windows as well.
- Open the Device Manager, expand Ports (COM & LPT), right-click on the COM port you want to check, and select Properties;
- Go to the Details tab, select Service from the Property dropdown list;
- Copy the service value that your COM port refers to. In our example, this is Serial;
- Download the Sysinternals Process Explorer utility from the Microsoft site;
- Extract the ProcessExplorer.zip archive to a local disk and run the procexp.exe or procexp64.exe (depending on the bitness of your Windows) as an administrator;
- From the Process Explorer menu, select the Find > Find Handle or DLL menu (or just press Ctrl+F on your keyboard);
- In the Handle or DLL substring search box, enter the name of the service that uses your COM port. In our example, this is serial. Click Search;
- Process Explorer will return a list of processes that are using your COM port. In our example, this is the putty.exe process with process ID 5380;
- To free the COM port, you need to kill this process using TaskManager.exe or with the command:
taskkill.exe /F /IM putty.exe
- So you unlock the specified COM port and can assign/reassign it to your device, driver, or application;
Clear COM Ports Using COM Name Arbiter Tool
Also, you can easily delete COM ports with the help of a third-party tool called COM Name Arbiter. It is completely free, and you can download it from the official website. This utility helps you to modify the registry parameter ComDB in a simple way without taking the risk of accidentally removing or editing the wrong strings in the Registry Editor.
Download the COM Name Arbiter Tool from the official website and run the executable file with Administrator privileges.
This tool’s main window shows the list of all COM ports and places a checkmark next to the currently occupied ports with present devices. If a device is not connected, hit Remove non-present devices. This will clear all assigned COM port numbers and make them available to assign. You can also clear the COM port manually, by unchecking a specific device from the list. This app automatically applies all the changes, so there’s no need to manually hit the Apply button.
Windows is now able to reassign the COM port number to a new device when the device is plugged in.
Note. One of the major drawbacks of the COM Name Arbiter utility is that it can only manage the first 256 COM port numbers.
You can also use a third-party tool called Device Cleanup Tool to remove non-present devices and clean up occupied COM ports. The Last Used column is available in the utility console, which allows you to understand when a particular device was used (the value is taken from the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum registry key). Right-click the device you want to uninstall and select Remove Device. This will also free up the COM port.
Note. Read our article on how to login with a local Windows account instead of domain account.
The Device Cleanup Tool is available for free from the official website.
Another handy tool for viewing COM port configuration is COM Port Info. This tool allows you:
- View assigned COM port numbers;
- Safely remove hardware;
- Change and swap COM port numbers;
- Reset USB Ports.
Delete Unused COM Ports Using CMD
Also, you can clean up assigned COM ports with the help of the DevCon.exe (Device Console) utility that comes built-in with the Windows Driver Kit (WDK), Visual Studio, and Windows SDK for desktop apps. In order to use DevCon, you will need to download and install the WDK.
- Run the Command Prompt as Administrator and paste the following command:
Cd %WindowsSdkDir%\toolsx64
- List the reserved COM ports using the command:
devcon findall =ports
- Now you can remove all unused ports using their IDs. For example:
devcon remove @”PCI\VEN_8086&DEV_A13D&SUBSYS_30BE17AA&REV_31\3&11583659&0&B3”
Note. Make sure you included the @ symbol before the device ID.
Thus, you can delete all unnecessary COM ports (if you try to remove the used device, the Remove failed error appears), and reassign them to different devices.
On Windows 11 and Windows Server 2022, you can use the built-in command PnPUtil instead of the devcon.exe utility.
List COM port devices:
pnputil /enum-devices /class ports
In this example, you can see that the COM3 port is occupied by a MediaTek USB Port device. This device is currently not connected (Status: Disconnected).
You can remove this device with the command:
pnputil /remove-device "USB\VID_0E8D&PID_0003\5&1082c90b&0&2"
Reset COM Ports Using the Registry Editor
Now, let us talk about the most challenging methods on how to delete COM ports in use. In this part, we won’t use any third-party tools. All that is needed is the Registry Editor which is a part of every Windows installation.
Caution. Back up the important data and create a system restore point. Follow the instruction strictly and be careful not to edit random fields. Breaking the COM ports assignment registry key may end up getting lots of BSODs. We are pretty sure you don’t want this.
- Disconnect all peripheral devices;
- Press Win + R on your keyboard. Enter the regedit command to run the Registry Editor;
- Go to the following path: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter. If you use Windows 10, just copy the path, and paste it into the address field;
- On the left side of a window, right-click COM Name Arbiter and select Export. Save the export to the com_name_arbiter_bak.reg file somewhere you can easily access it in case something goes wrong. In case of emergency, this will help you to restore the previous working settings;
- If you want to reset all COM ports, change the ComDB value to 0. ComDB’s binary value defines the list of reserved COM ports. Every bit defines the status of the corresponding port (1 to 255);
- You can also find the list of all assigned COM ports in the Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports path. You can delete all the ports you want to free up;
- Restart your computer. When it boots back, connect all the devices in the proper order.
That’s it! Now you know how to delete COM ports and reassign them to a different device.
29 comments
I have tried this in Win 7 x64 and I do not see the ports that are not connected. I am using a USB to Serial adapter (FTDI – virtual com) and when the usb side of the device is connected to the computer it shows in Device Manager, when the usb side of the device is not connected to the computer is does not show in Device Manager (even when using your directions)
Please advise!
Windows 10:
Right click start menu, click device manager.
In top menu, click “show hidden devices”.
Under COM ports, delete any ports you don’t want (right click and click delete).
Exactly the same for Windows 7 except open device manager by right clicking on Computer either on your desktop (if it’s there) or in the start menu, select Properties and then click on Device Manager on the left side.
I don’t why they give you all these arcane command line commands when it’s so simple to do the same thing in the GUI. After all, this is why GUIs were invented.
I tested this just a few minutes ago and yes, it looks like it has changed a little bit. Got it working. You need to do this. Open up Command Prompt, type: set DEVMGR_SHOW_NONPRESENT_DEVICES=1 and then hit enter. Then type: start devmgmt.msc. Then go up to view and show hidden devices. It should now show up even when it isn’t plugged in.
Hi Jay,
You need administrative privilege in Windows 7. Try enter cmd.exe and press Ctrl-Shift-Enter
Step #2 is not effective until you reboot the machine. At least on Windows XP SP3
@Patrick: Thank you for mentioning that, I have updated the post above.
This worked. Stupid Windows Vista decided it didn’t like com ports 1-14 anymore.
Thanks
It worked! Non present devices show up with the port number assigned right next to it.
That’s exactly what I needed.
Thank you Brian for sharing your wisdom!
I have over 1200 serial ports in use on my pc is there a way to uninstall several ports at 1 time?
First it didn’t worked for me. But then I booted in safe mode, and do this procedure.
It still didn’t worked, but then I started deleting all unnecesarry devices like usb disk drives and stuff.
After some while in Com&ports sections I managed to see some more devices with com ports assigned to them, and only then I could delete them.
Thanks, this worked for me. The driver initially can up as COM107. All my lower number COM ports were in use so I found these instruction to clear one of the ports:
https://theitbros.com/how-to-delete-com-ports-in-use
Worked like a charm, thanks! I suspected those little bastards were hiding somewhere and now I know how to find them. :o)
To those not getting it to work, you are probably not managing to set the environment variable properly (step 2). No reboot is required and you can see that you were successful if you instead do it like this:
* Bring up system properties dialog (Win+Pause alt. System in Control Panel) (In Vista/7 also click “Advanced system settings”)
* Go to the advanced tab and click the “Environment variable…” button. (Hint: You can also find the device manager in the hardware tab in the same dialog, unless you want to show off your command line ninja skills of course. ;o))
* Click a “New…” button, preferably the upper one but it doesn’t really matter.
* Fill in variable name devmgr_show_nonpresent_devices and Variable value 1.
After this all you have to do is reopen the dialog. (Tried on Win XP and Win7)
Yes, finally!
Thank you.
Thanks, worked a treat in Windows 7 (no reboot was required) when I replaced my motherboard. The com ports werent working and on checking the ports in use there were twice as many as there should be. Your tip allowed me to get rid of the old ones.
Great, glad this helped.
It doesn’t work on win7 home premium.
For windows 7 32bit, etc, be sure you are in the Windows directory. Type: cdWindows once you are int he command prompt, then follow steps 2,4,5,6 above.
Thank you for your comment!
Works, but I can only uninstall some comports, but not all are show, so I can’t free all my comports.
It does show nicely all my connected and unconnected devices.
hi, anybody know how to install a com port?
Hi Brian, got a quick question…what if you uninstall all the COMs and reboot but the COM ports come back and still show that they are in use when there is nothing being shown for the device(s)?
Is this machine a member of a domain? If so, you might try logging on as local administrator account and re-follow the steps above.
Yes, works a treat (reboot definitely required with XP Pro SP3). Many thanks!
Great, glad we could help!
thank you
I’ve used this procedure in Win 10, but it doesn’t show unused com ports
. How do you do it there?
Ok I figured it out never mind printers, removing to get comports etc..
Com Ports will not show until you connect a comport. So even though your comport is high and unusable (for a test) go ahead and activate it only then will you see it listed under ports you’ll see the comport shows up but its likely too high for your application, just an exercise so you can see comports will only show if you have something paired.
Now the reason you have all these unused comports is because drum roll …you have plugged in a multiple USB hub get it ? The hub causes unused com ports to be assigned so when you pair the one com port you need its sequentially high on the list, a number that won’t work. Remove the external hub then create the com port (pair) the one you want, once paired you’ll find your assigned a lower usable comport. Then, if you want, plug the hub in and it will assign comports above the lower number one you just installed. Computer will remember the comports unless you remove the lower comport, no worries just repeat the process to get the right comport.
Hope this works for you!
Hi, I supouse this will help me with my Bluethooth printer who is getting assigned COM18. Any who had the same issue?
1. Write down the name of the port used for the connection.
2. Open the printer screen so that the printer’s port settings can be changed.
3. Right-click the printer icon, and then;
Windows 7 / Window 8 /Windows 10:
click [Printer Properties].
Windows XP / Windows Vista:
click [Properties].
5. Click the [Ports] tab.
6. Select the port name confirmed in step 2 (“COM” plus a number).
7. Click [OK] to close the properties dialog box.
or you can try to create Virtual Serial Port with the help of virtual-serial-port*org and assign a COM port for the printer.