Port access is denied

Hi All,

Old problem, no solution. I am trying to upload any sketch to Nano and port access is denied. Was working just a few days ago, now not so much.

avrdude: ser_open(): can't open device "\.\COM2": Access is denied.

Here is what I've tried so far.

  • Restart (several times)
  • Changed port name (tried port 2, port 11, port 15, ...) Restarted after ever time
  • Checked windows firewall and allowed TCP and UDP for all inbound ports.
  • Tried different USB cables
  • Tried different Arduino microcontroller

I am using Arduino IDE 2.0.3 on Windows 11 Pro machine

Anything else I can try?

did you ensure your serial monitor is closed?

1 Like

I just learned that I have to do this... I don't recall this was an issue with older IDE versions, but it does seem to be an issue now.

Thanks it is working now.

Hi @MathPi. Thanks for your report.

There is a known bug that can cause Arduino IDE 2.x to have the behavior you describe under specific conditions.

I would like to determine whether you are affected by that bug problem. Please tell me which USB chip your Nano board has. The chip is usually located on the bottom of the board on the end nearest the USB socket.

The common chips:

FTDI FT232R

WCH CH340

(that picture is of the chip on an Uno board, but the chip on the Nano board would have the same markings and package as shown in the picture)

I am suffering the same problem. All was fine on Saturday morning then suddenly it started giving Com3 errors. I even tried using an old laptop running Windows 7 on which I installed an old 1.7 or 1.8 version of IDE, but both give the error mid way through compile/upload.
It’s a Nano BLE.

Hi @epmack. In order to gather more information that might help us to troubleshoot your problem, I'm going to ask you to post the full output from the upload when in verbose mode.


:exclamation: NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.


Please do this:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Uncheck the box next to Show verbose output during: β˜‘ compilation
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the OK button.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see a "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the COPY ERROR MESSAGES button on that notification.
  8. Open a forum reply here by clicking the Reply button.
  9. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  10. Press Ctrl+V.
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code tags before you add any additional text to your reply.
  12. Click the Reply button to post the output.

Hi,

Yes on the Genuine Arduino Nano I am using is the FTDI chip. I've attached a photo for your reference.
Nano_FTDI

Thanks @MathPi! The Arduino IDE developers are tracking this bug here:

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments related to this subject.

There was no intention of designing Arduino IDE 2.x so that it would be necessary to close Serial Monitor before uploading. The IDE is designed to allow uploads even with Serial Monitor open. Hopefully the bug will be fixed soon.

1 Like

Thanks, I subscribed on Github to follow this development. I can't tell you how often I now forget to close the serial monitor and then it not uploading properly :wink:

Hi, and thank you for helping to look into this. Please see below and do of course say if there's any more info I can provide.
I'd add that as best I can see, the chip by the USB Port is labelled WR1 and then, vertically, oO.
Kind regards,
Ed

Sketch uses 97504 bytes (9%) of program storage space. Maximum is 983040 bytes.
Global variables use 46064 bytes (17%) of dynamic memory, leaving 216080 bytes for local variables. Maximum is 262144 bytes.
Performing 1200-bps touch reset on serial port COM3
Waiting for upload port...
No upload port found, using address:"COM3" label:"COM3" protocol:"serial" protocol_label:"Serial Port (USB)" properties:{key:"pid" value:"0x805A"} properties:{key:"serialNumber" value:"E7763601C2C8AE65"} properties:{key:"vid" value:"0x2341"} as fallback
"C:\Users\edmac\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino2/bossac.exe" -d --port=COM3 -U -i -e -w "C:\Users\edmac\AppData\Local\Temp\arduino-sketch-5BA0F86354A0076DE369083EA2835935/Date + Temp.ino.bin" -R
No device found on COM3
Failed uploading: uploading error: exit status 1

My PC does seem to recognise the Nano 33 BLE on its COM Port, btw:

The Nano 33 BLE is different from the classic Nano mentioned previously in this thread in that its nRF52840 microcontroller has native USB support, so it does not have a dedicated USB chip like the FTDI FT232 on the official classic Nano.

The way uploads to this type of board works is:

  1. Arduino IDE (or the upload tool used by Arduino IDE) sends a signal for the microcontroller to run the bootloader program.
  2. The microcontroller starts the bootloader program.
  3. The bootloader program runs and waits (normally only for a short time) for an upload to start.
  4. The upload tool sends the program to the microcontroller, where the bootloader program writes it to flash memory.

The way the IDE signals the microcontroller to run the bootloader program is by opening a serial connection at 1200 baud. There is some special code running on the microcontroller in the background of your sketch that recognizes that 1200 baud connection as a special signal.

In some cases, your sketch code might cause that 1200 baud detection code to be missing or not working correctly, which will mean the bootloader never runs and the upload fails with the error you're seeing.

The fix is to manually put the board into a mode where the bootloader program runs persistently before you do an upload.

Try this:

  1. Press and release the reset button on your board quickly twice.
    You should now see the LED on the board pulsing, which means the bootloader is running.
    The double reset causes the bootloader to run until the board is reset normally, powered off, or an upload is done.
  2. Select the port of your board from the Tools > Port menu.
    The port may be different when the bootloader is running so don't assume you already have the correct port selected.
  3. Start an upload in Arduino IDE.

The upload should now finish successfully.

After this, you should be able to go back to doing normal uploads without needing to use the reset button technique. If you still need to do the reset trick to do uploads after this, the problem may be caused by your code. You can verify this by uploading a simple sketch like File > Examples > 01.Basics > BareMinimum.

Thank you, this has worked. I am grateful for your help and guidance.
Ed

You are welcome. I'm glad it is working now.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.