Frequent COM port in use errors - ESP32 - Windows

More than 50% of the time I use “Upload and Monitor” PIO reports the COM port is in use. It should not be in use, I have tried deleting the “Upload and Monitor” terminal in VSCode, it doesn’t always fix the issue either.

This is a huge hit to efficiency when in the edit/compile/test cycle.

Anyone have a recommendation as to how to address this?

Check whether another VS Code terminal, Arduino Serial Monitor, PuTTY, Tera Term, etc. has the COM port open.

Hi, three try to check the port first via device list and then add this port during upload.

This usually means a serial-monitor process has not released the port before the upload begins. Stop the monitor with Ctrl+C, wait briefly, and run Upload separately. Also define the port explicitly:

upload_port = COM5
monitor_port = COM5

Make sure Arduino IDE, PuTTY, other VS Code windows and serial-monitor extensions are closed. Microsoft Process Explorer can search for COM5 and identify the process holding it.

To determine whether the issue is specific to PlatformIO or affects the Windows serial driver generally, try one upload outside PlatformIO. This Arduino CLI guide explains how to compile and upload ESP32 firmware from the command line.

If command-line uploads work consistently while “Upload and Monitor” fails, the likely cause is a PlatformIO monitor-release timing issue.