MEGA2560 Failed uploading error COM

Hi, I'm using Arduino Mega2560 R3 for some days ago and I detected a problem when use the Serial Monitor.

Each time that I compile a program with serial instructions... Serial.begin(9600) and Serialprintln(STATUS) for example... when I try download the program in Arduino, the first time it works well but if I download a second time, Arduino IDE (2.00rc9.1) show this message:

Failed uploading: uploading error: exit status 1avrdude: ser_open(): can't open device "\.\COM6": Access denied.

After check all parameters, check windows (Win11) com ports, restart the computer.... but nothing, the port is blocked.

I need to follow this instructions for restard the port each time:
https://support.arduino.cc/hc/en-us/articles/4407830972050-Find-and-stop-process-blocking-a-port

Does anyone know why this happens?

Thank you for your time.

Hi @dracorp76. Thanks for your report.

There is a bug in Arduino IDE 2.0.0-rc9.1 that causes uploads to fail when Serial Monitor is open:

This bug has already been fixed and is available from the latest nightly build of Arduino IDE 2.x.

The download links for the nightly build are listed on the "Software" page here:

https://www.arduino.cc/en/software/#nightly-builds

Please give the nightly build a try and then let us know if you still have troubles uploading.

Thank you very much @ptillisch for your quick answer and solution.
Best regards.

You are welcome. I'm glad if I was able to be of assistance.

By the way, since the time I wrote my previous reply, Arduino IDE 2.0.0-rc9.2 was released. This version has the upload bug fixed, so you can use that version if you like.

The nightly builds are useful for those who want to contribute to the development of the IDE by doing beta testing and then reporting any bugs they find. If you are interested in doing that, by all means feel free to continue using the latest nightly builds.

Hello @ptillisch, I'd like ask you again for some problems with COM port.

I have instaled Arduino IDE 2.0.0-rc9.2 and some time works well and others not.
My problem is when I download a program with Serial.begin(9600), when the Arduinos restart, if USB is connected, It didn't work the first time... I need to unplug the USB, to do a power off in Arduino, wait 5 secons, to do power on, connect the USB and to do a reset in Arduino board again, if not to do this, I can't read serial data.

If I download a program without "Serial data", works well or If a power on the Arduino and USB is unplug, works well.

Do you hace any idea of the problem?

Best regards.

By "Arduinos", do you mean Arduino Mega 2560 boards, or are you using other types of Arduino boards?

Please provide a detailed description of what you mean by "didn't work".

If you are getting any error or warning messages, please provide the full and exact text of those messages.

My Arduino it's an Original Arduino Mega 2560, you can check it in this video.

In this video, you can show exactly the problem (here you have a link):
[Dropbox - Ard_1.mp4 - Simplify your life]

Time line
00:00 to 0:30 - Compile and download, but the Serial Monitor it doesnt work, only appear squares...
00:30 to 01:33 - I need to do a reset, unplug USB, unplug power,to plug power, to plug USB again, and to do reset 2 times.
01:34 to 01:53 - Serial monitor works well
01:54 to 02:20 - Compile and download again, but Serial Monitor it doesn't work
02:21 to 02:44 - I need to do a reset again for restart Serial data.
02:45 to ens - Same to previos step.

Here you have other video with same problem...
[Dropbox - Ard_2.mp4 - Simplify your life]
Compile and download and nothing.
Reset 2 times the Arduino and nothing
BUT, in timeline 01:38, I unplug USB, restart Arduino and works well, I connect again the USB and system down. I need to restart again.

The problem always is the USB, if it's connected, serial monitor fail, but if it's unplug, works well.

I hope that these videos can help you to understand better the problem.

Best regards.

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