Fix “Cannot configure port, something went wrong … PermissionError(13)”
Windows refused to configure the COM port because the USB device stopped responding. Replug, change cable or port, and update the CH340/CP210x driver.
Community draft — report a mistake
What you see
esptool.py v4.6
Serial port COM4
Connecting...
A serial exception error occurred: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection (e.g. range extenders, USB hubs) or drivers.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed uploading: uploading error: exit status 1esptool.py v4.6 Serial port COM4 Connecting... A serial exception error occurred: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31) Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection (e.g. range extenders, USB hubs) or drivers. For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html Failed uploading: uploading error: exit status 1
pySerial asks Windows to set the baud rate and handshake lines before esptool says a single word to the chip. “Cannot configure port” means Windows itself could not do that, because the USB device behind the COM port is not responding.
That makes it a connection problem, not a code problem. Change the cable and port first, then the driver.
Quick fix — try in order
- 1
Plug the board into a different USB port
Windows error 31 means the USB device stopped answering. A fresh enumeration on another port fixes most cases.
- 2
Swap the cable
A cable with a broken data wire connects and disconnects as you move it. Cheap cables from local shops are the usual suspect.
- 3
Update the USB-serial driver
Check Device Manager → Ports for the chip name. CH340 → install the latest WCH driver; CP210x → Silicon Labs driver (links below). Then unplug and replug.
- 4
ESP32-C3/S3 native USB: enter download mode by hand
Hold BOOT, tap RESET, release BOOT, then upload. A crashing sketch makes the native USB port misbehave exactly like this.
- 5
Remove power-hungry parts during upload
Relays, servos, LED strips or a camera powered from the board's 5 V pin can make the USB chip reset when the ESP32 starts transmitting.
Why it happens
What does “A device attached to the system is not functioning” mean?
It is Windows error 31. The port exists in Device Manager, but when esptool tried to set the baud rate, the USB device did not respond. The cause is almost always physical (cable, port, power) or a driver problem.
It worked yesterday
Windows Update sometimes replaces the CH340 or CP210x driver with an older version. Reinstalling the maker's driver fixes it.
Only fails at 921600
Some clone USB chips cannot switch to high baud rates. Set Tools → Upload Speed → 115200.
Board-specific notes
ESP32-CAM with MB programmer: The ESP32-CAM-MB's CH340 shares 5 V with the camera. A weak cable makes it brown out — use a short, thick cable straight into the PC.
Drivers — official sources only
Did this fix it?
Thanks — that helps us keep this page right.