ESP32 & could not open port 'COM5': PermissionError(13, 'Access is denied.', None, 5)


I have a problem with the Virtual Port COM CP210x

In the platformio I have the following message :
— Available filters and text transformations: colorize, debug, default, direct,
esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting... could not open port ‘COM5’: could not >> open port ‘COM5’: PermissionError(13, ‘Access is denied.’, None, 5)
The terminal process “C:\Users\josem.platformio\penv\Scripts\platformio.exe ‘device’, >> ‘monitor’, ‘–environment’, ‘esp32doit-devkit-v1’” terminated with exit code: 1.

I have reinstalled the latest CP210x driver for Win10 but It still does not work

Please help me on this topic
I was stuck on this.

Thank you in advance

Jose Miguel

You might have already a serial monitor open, thus preventing from it being opened again. Check and close (Ctrl+C) previous PlatformIO monitor instances.

I had a similar problem. As far as I could tell, nothing was attached to the COM port. Earlier before I had uploaded the ESP32 (M5StickC+) filesystem image successfully, but then when I went to upload the code, this came up. Tried restarting PI, disconnecting and reconnecting the M5, powering off and on the M5, closing all terminal sessions, starting a monitor session and then closing, no luck.
What seemed to work was disabling and re-enabling the COM port in Device Manager.

1 Like

Well, seems I spoke too soon. Tried making changes and uploading again, getting Access Denied again for the COM port. I did have the monitor open originally but I had closed it.
Disabling and re-enabling the COM port didn’t work this time.

As a test I tried uploading with the COM port disabled, got error “can’t find file specified” which is what I would expect.

I wonder if the default upload speed is the problem.

1 Like

Further troubleshooting: using Arduino IDE (and with PI shut down) I had no issues uploading code to the M5, but after closing that and trying to upload with PI, same “access denied” issue.
Monitor works though.

1 Like

I see exactly the same problem. Disabling/enabling in the device mananger does not help. I have this:
SerialException: could not open port ‘COM76’: PermissionError(13, ‘Adgang nægtet.’, None, 5).
Zadig driver is installed OK.
I experience the same problem on a different machine.
If I disconnect the USB, then COM76 and Dual RS232 disapears. How do I convince platformIO that this is the free port to use?
Could the Dual RS232-HS interface0 marked “red” in the tool “usbdeview” have something to matter?

Notice that the tool claims the serial port is unsafe to unplug. It should be disabled before disconnecting.

The error message comes from Windows, not PlatformIO. Every serial program that attempts to open the COM port will experience the same error message.

Can you check with what program is holding a handle on COM76?

Thanks for a quick answer. I tried to run the Intel tool, and followed it to the letter. However the result is not as expected
just need to find a solution … :roll_eyes: :+1:

With process explorer they mean Process Explorer - Sysinternals | Microsoft Learn

Hi again
My god - Intel had a similar Process Explorer - and that was the one I got started
I found a User manual for the Microsoft Process Explorer (link enclosed)

Anyway I am not sure what I see… searching for FTSER2K
I have the platformIO running with the monitor active. Nothing shows up.
I clicked on terminal and restarted it - still nothing…

AHAA… now we are getting somewhere.
I started another job on the very same port and this time we got Com12 !!!
This driver origins from Microsoft on Com12 USB\VID_04D8&PID_F55F\6&364B1209&0&1 sitting on a microchip PIC24-processor.

And the handle show correctly “usbser”.
So - is this a driver problem?

Now I have tried the same job on another machine - with a different ESPPROG - still the same problem. This time Com77. The process does not show up.

NOPE - No serial job is engaged. Nothing shows up in the process Explorer. Don’t really know what to do… many desperate attempts.

A fresh log coming here - the port is seen as working during upload. However it does NOT work - at the very last it suddenly blocks the port - even it has just been working:

> Executing task in folder 1_1_Hello_World_WS: E:\ESP\ESP_IDF\penv\Scripts\platformio.exe run --target upload --environment esp32dev <

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
 - framework-arduinoespressif32 3.10006.210326 (1.0.6)
 - tool-esptoolpy 1.30100.210531 (3.1.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 30 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESP Async WebServer> 1.2.3
|   |-- <AsyncTCP> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <AsyncTCP> 1.1.1
|-- <WiFi> 1.0
Building in release mode
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  13.2% (used 43124 bytes from 327680 bytes)
Flash: [=======   ]  71.0% (used 931210 bytes from 1310720 bytes)
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM78
Uploading .pio\build\esp32dev\firmware.bin v3.1
Serial port COM78
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None        
Crystal is 40MHz
MAC: 7c:9e:bd:cd:24:f0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000f3fff...
Compressed 17104 bytes to 11191...
Writing at 0x00001000... (100 %)
Wrote 17104 bytes (11191 compressed) at 0x00001000 in 0.6 seconds (effective 219.5 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 305.2 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.2 seconds (effective 411.8 kbit/s)...
Hash of data verified.
Compressed 931312 bytes to 532484...
Writing at 0x00010000... (3 %)
Writing at 0x0001b15f... (6 %)
Writing at 0x00027729... (9 %)
Writing at 0x000351dd... (12 %)
Writing at 0x00043223... (15 %)
Writing at 0x00049408... (18 %)
Writing at 0x0004f511... (21 %)
Writing at 0x0005468b... (24 %)
Traceback (most recent call last):
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 435, in command
    p =
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 380, in read
    return next(self._slip_reader)
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 3021, in slip_reader       
    raise FatalError("Timed out waiting for packet %s" % waiting_for)
__main__.FatalError: Timed out waiting for packet header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 4582, in <module>
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 4575, in _main
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 4122, in main
    operation_func(esp, args)
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 3424, in write_flash       
    esp.flash_defl_block(block, seq, timeout=timeout)
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 149, in inner
    return func(*args, **kwargs)
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 874, in flash_defl_block   
    self.check_command("write compressed data to flash after seq %d" % seq,
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 462, in check_command      
    val, data = self.command(op, data, chk, timeout=timeout)
  File "E:\ESP\ESP_IDF\packages\tool-esptoolpy\", line 451, in command
    self._port.timeout = saved_timeout
  File "E:\ESP\ESP_IDF\penv\lib\site-packages\serial\", line 372, in timeout
  File "E:\ESP\ESP_IDF\penv\lib\site-packages\serial\", line 222, in _reconfigure_port
    raise SerialException(
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: PermissionError(13, 'Adgang nægtet.', None, 5)
*** [upload] Error 1

Does uploading work in the Arduino IDE?

Hello josemiguel.
Had a similar problem, but then with COM3. Sometimes it loads, most of the times not … very frustrating. It seems as if PlatformIO is having some kind of control over some (lower numbered) COM ports, which seem virtually free, but are in fact not really free. The user cannot identify these port reservations (I would appreciate if someone can confirm this). Hard to find solutions on the internet, though I managed to solve it as follows:

  1. In device Manager, under “Ports (COM & LPT)”, right click on the Silicon Labs one
  2. go to “Properties” - “Port Settings” - select “Advanced”
  3. In the “Advanced Settings for COMx”, select a COM port > 10, whioch is free (in my case I selected arbitrarily for COM17)
  4. Click “OK” to close “Advanced Settings” and 2nd time "OK to close “Properties”
  5. In “platformio.ini” add a line 'upload_port = COMx (where x was 17 in my case). To my belief this setting in ‘platformio.ini’ is not a requirement, though it does noet hurt :wink:
  6. Unplug the USB from the PC, re-plug it in and check that the Device Manager is indicating the correct COM port.

This worked for me without any problem up to now. I would be glad however to learn more on this topic and would be greatful to learn why COM3 is not giving the same positive response.

1 Like

Sorry for the delay… but there is a reason. :smiling_face_with_tear:
I did not try the Arduino IDE on this machine. I don’t know - BUT I think I know the reason now. I bought a new PC and started all over from scratch. Everything with default settings.
This USB-port has troubled me on many other occasions - I have both a USB-port extender and the native USB-port. They react a bit differently and the best is the native build in port. I am a bit nervous to use the native because I have experienced damaged ports (because of all my experiments with electronics) - so I prefer to use an extender.

I installed Arduino on the new machine - it worked.
Then I tried PlatformIO - it worked. :grinning:

So I am happy and can go on experimenting - it’s so much fun…
Thank you for your kind support - I have donated a small amount to keep you up and running.

Solved in my case:

It was the pyMakr extension that tries to auto connect to the device even when I am not using it.

Open pyMakr.json (ctrl+shift+P → pyMakr → Global settings) and set “auto_connect” to false
Close any related terminal

BRO, you just need to uninstrall the ch340 driver,and reinstall it, it will definintely work fine, atleast it worked for me ,


Thanks you so much. I created my account just to say that :rofl:
You saved me so much troubles !

I uninstalled the driver and the system installed it again, same problem.

Found the solution here:

By installing old CH340 driver and connecting the board on USB 2.0 port.