Avrdude ser_open can t set com-state for COM5

I’m sure that everyone who has ever tried to upload a sketch from the Arduino IDE has seen this error message:

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

The number of the serial port can be different, but the error is the same.

Basically (in simplified form) this error means that the USB port is in use by another application in your computer, so the Arduino IDE cannot use it to upload your sketch. It is important to understand that this error has nothing to do with Arduino, the access to the serial ports are controlled by the operating system.

Tip #1: Check your port in Device Manager

Open Device Manager and check that your IoT device appears in the Ports (COM & LPT) section. Note the number of the port (in my case COM4):

Avrdude ser_open can t set com-state for COM5

Tip #2: Check your port in the Arduino IDE

Open Arduino IDE and check in the Tools –> Port menu that you are trying to upload to the port you have seen in the Device Manager. The Arduino IDE is quite good to detect connected devices, but in case you have multiple devices connected at the same time this is definitely worth to check:

Avrdude ser_open can t set com-state for COM5

Tip #3: Close other programs

Try to close any programs that may use this port. Unfortunately I’m not aware of any tools that could list which app is locking a particular port (if you do, please share in the comments), so you have to think. Basically any app can be the culprit that communicates with devices, and unfortunately not only apps, but device drivers also. For example some Bluetooth drivers are reported to lock COM ports even before a device is connected.

In my experience the following apps are often causing this problem:

  • Code editors: Do you have other open Arduino IDEs, Visual Studio Code instances or apps that you use to create and upload your code open?
  • Terminal monitors: Do you have a terminal monitor connected? Sometimes they are separate apps (like Termite) or built into code editors (like in Arduino IDE or in Visual Studio Code).
  • Apps and drivers for other devices: Do you have other devices connected to your computer via USB or Bluetooth, e.g. a printer, a vinyl cutter or a 3D printer?

Tip #4: Rename the port

If none of the above works you can rename the port, and most of the time this is what fixes the issue for me.

1. Open Device Manager and navigate to the Ports (COM & LPT) section (see the screenshot above).

2. Right click your COM port and select Properties.

3. In the  Properties window first click Change settings to switch to administrator mode, then navigate to the Port Settings tab:

Avrdude ser_open can t set com-state for COM5

4. In the Port Settings tab click the Advanced button:

Avrdude ser_open can t set com-state for COM5

5. In the Advanced Settings window select a new COM Port Number:

Avrdude ser_open can t set com-state for COM5

Click OK and close all Device Manager windows. Windows may ask you to restart your computer, but in my experience the Arduino IDE is quite smart to detect port changes immediately.

Did this help you? What other tricks do you have when uploading a sketch fails?

  Welcome, Guest. Please Login or Register
Avrdude ser_open can t set com-state for COM5
 
 

Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
 
Avrdude ser_open can t set com-state for COM5
Home
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Search
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Tutorials & Wiki
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
visualmicro.com
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Login
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Help
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Register
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
   
  Visual Micro › › › Can't upload anymore (SOLVED - USER ERROR)

Avrdude ser_open can t set com-state for COM5
Can't upload anymore (SOLVED - USER ERROR) (Read 6996 times)

Bob Jones

Full Member

Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5

Offline

Posts: 210
Bellingham, WA

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore
Reply #20 - Jan 22nd, 2016 at 12:05am
 

I updated the driver with interesting results. I can load a sketch to an Arduino UNO using the Arduino IDE. It loads on COM6. I then attempt to load the same sketch using VS/VM and pointing it to COM6. It fails to load and says, "avrdude: ser_open(): can't open device "\\.\COM5": The system cannot find the file specified."

Eventually, after exiting VS and restarting a couple times, I got it to attempt to load on COM6, but the tx/rx led's on the board show no traffic and the output window says "Programmer is not responding".

I removed the arduino usb device again and re-scanned the hardware. Now it shows COM4 and COM5 but VS/VM shows only COM6! And closing and opening VS doesn't change the result.

Back to top

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged
 

Bob Jones

Full Member

Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5

Offline

Posts: 210
Bellingham, WA

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore
Reply #21 - Jan 22nd, 2016 at 12:49am
 

Would it help/make sense to use an FTDI driver like the SparkFun FTDI Basic Breakout - 5V?

I am getting very frustrated by this and I don't know how to proceed here. Everything I try seems to turn to mud. HELP!

Back to top

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged
 

Tim@Visual Micro

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore
Reply #22 - Jan 22nd, 2016 at 1:07pm
 

It sounds like .NET is confused did you try to restart your pc (power off)

Otherwise manually change the port in device manager to something else via right click

Back to top

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged
 

Bob Jones

Full Member

Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5

Offline

Posts: 210
Bellingham, WA

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore
Reply #23 - Jan 26th, 2016 at 12:51am
 

I have tried repeatedly to get the driver working with only partial success. I can compile and upload sketches using the Arduino IDE but the VS/VM IDE fails every time.

I have attached a simpler sketch (no external libraries) to show the problem. The compiler output is in output.txt in the root folder.

The results are identical every time: the upload failed:

Uploading to I/O board using 'Arduino as ISP'
Uploader started for board Arduino/Genuino Uno
Uploader will use programmer name: arduinoasisp
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude "-CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -cstk500v1 -PCOM3 -b19200 "-Uflash:w:C:\Users\Bob\AppData\Local\V.Micro\Arduino\Builds\TimerInterruptExamp
le1\uno/TimerInterruptExample1.ino.hex:i"
avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch
         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
         Using Port                    : COM3
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
Error during upload using programmer
Upload timed out waiting for a response

Upload failed

Upload timed out waiting for a response

Avrdude ser_open can t set com-state for COM5

Upload failed
The uploader returned an error
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
avrdude done.  Thank you.

Back to top

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged
 

Tim@Visual Micro

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore
Reply #24 - Jan 26th, 2016 at 1:21am
 

Hi,

Please answer these two questions...

Is the Arduino Mega the ISP and the Arduino Uno the board you are trying to program with a sketch (via the Mega)?

Is the Arduino Uno on COM3?

It's exactly the error I would expect if you do not have a board setup to be an ISP. What are you clicking in the Arduino Ide to upload?

Maybe you just need to switch "Always use programmer for upload" on the "Visual Micro" menu off. Did you switch it on because of ...

Quote:

The Arduino IDE makes it look like "Arduino as ISP" is being used but it is not unless you click "Upload using programmer". An ISP is not normal usb upload.

Thanks

Back to top

« Last Edit: Jan 26th, 2016 at 1:36am by Tim@Visual Micro »  

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged
 

Bob Jones

Full Member

Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5

Offline

Posts: 210
Bellingham, WA

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore
Reply #25 - Jan 26th, 2016 at 5:56am
 

I have been experiencing the upload problem with both the Mega and the Uno. The UNO is on COM3 and the MEGA comes up on COM4 or COM5.

At any given time, I have only one of these two boards / sketches loaded, but the problem occurs with ALL boards.

The programmer is currently "Arduino as ISP" and the Always Use Programmer for Upload is enabled, but the graphic is not very bright so it is easy to miss seeing what state it is in.

I just turned the "Always Use Programmer" feature off and VOILA! it uploaded. Finally!

Thanks, Tim.

Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5
Avrdude ser_open can t set com-state for COM5

Back to top

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged
 

Tim@Visual Micro

Avrdude ser_open can t set com-state for COM5
Re: Can't upload anymore - (SOLVED - USER ERROR)
Reply #26 - Jan 26th, 2016 at 2:16pm
 

Yes you hit the problem because you switched on "always upload using programmer" by mistake.

Back to top

« Last Edit: Jan 26th, 2016 at 2:18pm by Tim@Visual Micro »  

Avrdude ser_open can t set com-state for COM5
 

Avrdude ser_open can t set com-state for COM5
IP Logged