Each time when you connect a new COM device or a USB device (true for modems, smartphones, Bluetooth, serial-to-USB converters, etc.), Windows detects it using Plug-n-Play and assigns it a COM port number in the range of 1 to 255. If this device is connected again, the reserved port is re-assigned to it. A new device gets the first free or available COM port number. This ensures that there are no conflicts when two of the devices are attached at the same time.
Occasionally, multiple com ports will be classified as reserved or "in use" even though there is not a COM device or a USB device currently associated with it. If this happens frequently enough, it is possible that all of the free or available com ports become reserved and the system is exhausted of COM ports as there is a limit.
The reserved or "in use" port information is stored in the Windows Registry in a key named COM Name Arbiter that can be modified to remove the "in use" or reservation for COM ports that are not actually in use.
To fix the condition to unmark unused ports that are in use, you have to modify the Windows Registry, which we do not recommend doing. There is a program that you can use to do this for you and remove most of the risk associated with modifying the Registry called COM Name Arbiter Setter V1.0 (http://www.uwe-sieber.de/misc_tools_e.html#arbiter). It has to be run as an Administrator to modify the registry.
In real life, the users do not use their COM devices (as USB to COM adaptors) at the same time, but the COM numbers increase and increase because the reservation is not removed when the COM port device is uninstalled from the Device Manager. After 25 years Microsoft finally fixed this in Windows 10 version 1903, here the reservation is removed when a device is uninstalled, so this tool isn't needed anymore...
However, you may need to clean up from past com port allocations.
When you run it, click on the Clear unused Reservations and Remove non-present devices buttons to clean up com port allocations.