Could not open COM…, the port is busy or doesn't exist

  • ESP32
  • ESP8266

You may see

A fatal error occurred: Could not open COM99, the port is busy or doesn't exist.
Hint: Check if the port is correct and ESP connected
could not open port 'COM99': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
PermissionError(13, 'Access is denied.', None, 5)

Why it happens

  • FileNotFoundError: the port doesn't exist, so the cable, driver or port choice is wrong.
  • PermissionError / Access is denied: another program has it open.

How to fix it

  1. Read which of the two it is.
  2. Wrong door: unplug and replug, choose the port that appears, install the CP210x or CH340 driver if none does.
  3. Busy: close the Serial Monitor, other IDE windows and Python scripts, then replug.

It worked if: "Connecting…" appears after you press Upload.

Seen in a real run (some lines are close variants of it). Produced with esptool 4.8.1 on a port that doesn't exist; the access-denied line is Windows' usual wording. Sources: Espressif esptool: troubleshooting.

Didn't help? Search another error or ask us.