I have a handful of cheap ESP32 development boards, and some expensive, that all sometimes gives me the error A fatal error occurred: Could not open COM6, the port doesn't exist. But I have found a workaround.

The simplest way I found is to start with opening the Serial Monitor (in Arduino IDE) to see the status of the com-port easily.

Then unplug the USB cable from the dev-board, hold down the EN / reset switch while plugging it in again. If it worked (which it does 9/10 times) the yellow bar should disappear. If it doesn’t, just repeat again, it has never failed me yet.

Edited to add: I failed to mention that it is important to wait until Arduino IDE finishing it’s attempt to upload before disconnecting and connecting again. Alternatively shut down the Arduino IDE seems to help also.