Every time you plug in a COM or USB device to your computer, Windows creates a virtual COM port and assigns it to a device. A new COM port with a unique number from 1 to 255 is created for each connected device (COM1, COM2, COM3, etc). Even if you unplug (turn off) the external device from your computer, the COM port number assigned to it remains reserved (Windows shows it as “in use”). This may exhaust free virtual COM ports on the computer.
In this article, we will show you how to delete COM ports in use or change assigned COM port numbers on Windows.
Note. Although modern computers almost never have physical serial COM ports (such as RS-232), virtual COM ports are still commonly used in Windows for emulated ports created by USB (USB-to-UART, USB-to-COM, USB modem, card/RFID reader) and Bluetooth adapters.
Table of Contents
How to Manually Change COM Port in Windows
Some legacy apps can only address COM port numbers 1 to 9. If your device is assigned a high COM port number, you can change it manually using Device Manager.
For example, Windows has reserved the COM24 port for your device, but you need the COM9 port number.
- Press Win + R and run devmgmt.msc command;
- Expand Ports;
- Find the device you need to change COM port number and open its Properties;
- Go to the Port Settings tab and click the Advanced button;
- Select a new COM port number from the COM Port Number drop-down list.
- 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.
These steps won’t help if Windows says the COM Port you need is already in use. In this case, manually delete the used COM port and reassign it to a new device.
Delete COM Ports in Use on Windows
You can clear the COM port reservation for a device that is not connected to the computer.
- Open the open the Device Manager (Win + R > devmgmt.msc > OK), and select View > Show Hidden Devices from the menu. This allows to show disconnected COM devices;
- Expand the Ports (COM & LPT) section. The COM port number reserved for each device is shown. Disconnected devices have grayed-out icons;
- Find the disconnected device with the COM port number you need to free and right-click and Uninstall;
- DO NOT check the option “Delete the driver software for this device”;
- Repeat these steps until all grayed-out COM ports are removed;
- You can now assign a free COM port number to the device you need.
How to Check Which Program Uses the Serial (COM) Port
In some cases, to free up a serial port (COM port), you will need to find out which application is using the port.
You can use the Process Explorer tool to check which particular Windows process is using the COM port.
- 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 website;
- Extract the ProcessExplorer.zip and run the procexp.exe or procexp64.exe (depending on the bitness of your Windows) as an administrator;
- Select the Find > Find Handle or DLL in the to pbar menu (or press Ctrl+F);
- 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 process that is 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
- You have unlocked the COM port and can assign it to your device.
Clear COM Ports Using the COM Name Arbiter Tool
Also, you can easily delete COM ports using the free third-party tool called COM Name Arbiter.
Download the COM Name Arbiter Tool from the official website and run the executable file with Administrator privileges.
Tool shows the list of COM ports with checkmark next to the currently busy ports of connected devices. Press the Remove non-present devices to clear all assigned COM port number reservations.
You can also clear the COM port manually, by unchecking a specific device from the list.
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.
Removing Unused COM Ports via CMD
You can use the built-in PnPUtil tools to list and remove assigned COM ports from the command prompt.
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).
Copy the Instance ID and remove this COM 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 difficult low-level method of deleting used COM ports in Window.
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. You can make direct changes to the registry to reset COM port reservations.
Caution. It is recommended that you create a system restore point before making these registry changes.
- Disconnect any peripheral devices from the computer;
- Open the Registry Editor (regedit.exe);
- Go to the reg key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter;
- Right-click on the COM Name Arbiter key, select Export, and save the backup of this registry key to the *.REG file. This allows you to restore previous settings if something goes wrong;
- If you want to reset all the COM port assignments, 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 HKLMACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports key. You can delete any ports you want to free up;
- Restart your computer. When it boots back, connect all the COM devices in the proper order.
Now you know how to delete COM ports and reassign them to a different device.