Access is denied only sometimes

I can't figure out how this can work.

I own a Genuino Uno, and sometimes I can upload my sketch to it, but some other times (most of the times unfortunately) it just gives the famous error:

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

And I really can't understand the logic in that
Why does it only work rarely?

Which version of the Arduino IDE are you using?

Which version of the Arduino IDE are you using?


Are you using Windows? I think it's the same problem as: Arduino 1.6.8 constantly polling serial, resetting Arduino board, Access Denied - Installation & Troubleshooting - Arduino Forum. This issue is isolated to Arduino IDE 1.6.8 and the Arduino developers are working on a fix for it. So if you want to test out the fixed version of the IDE you can download it from Rework serial ports handling by facchinm · Pull Request #4792 · arduino/Arduino · GitHub(and please post your results) or you can also switch to using Arduino IDE 1.6.7 and that should also fix the problem.

I am using Windows. Will try and edit with the results.

Thanks a lot for your kind help

I downloaded the fixed version of the IDE and it does the exact same thing
Worked the first time, now it doesn't work

Update: Works perfectly with 1.6.7

Thanks a lot!