Random Error Uploading to Arduino MEGA Board

Hi,

I have been getting an error about “can’t open device COMx,” when I try to upload a sketch to my Arduino Mega 2560. This error does not happen all the time, but it happens randomly and I am not able to identify why it occurs. I have looked at several forums and I have checked all of my COM ports, disconnected any bluetooths that might be causing the problem, and I have even switched Arduino Mega boards. However, this issue still occurs randomly.

Do you have any advice for what could be causing this to occur? Below is the error if that will be more helpful to look at:

“Arduino: 1.6.8 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 11,316 bytes (4%) of program storage space. Maximum is 253,952 bytes.
Global variables use 764 bytes (9%) of dynamic memory, leaving 7,428 bytes for local variables. Maximum is 8,192 bytes.
avrdude: ser_open(): can't open device "\.\COM4": Access is denied.

avrdude: ser_drain(): read error: The handle is invalid.”

Thanks for your time!

Some people have reported that revision 1.6.5 of the IDE is best.

This may be caused by a known issue with Arduino IDE 1.6.8, Windows and FTDI: Arduino IDE 1.6.8 - Can't open device error while uploading (No issue in 1.6.7) · Issue #4700 · arduino/Arduino · GitHub which has already been fixed. If that's the problem it sill be fixed by using any IDE version previous to 1.6.8 or if you're feeling adventurous try the hourly build: http://www.arduino.cc/en/Main/Software#hourly