Problem when uploading code arduino mega 2560

This is eror code i get.
avrdude: ser_open(): can't open device "\.\COM4": The system cannot find the file specified.
avrdude: ser_drain(): read error: The handle is invalid.

avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

Hi @bicaninf. This error might be caused by having the wrong port selected from the Tools > Port menu in Arduino IDE.

Please perform this experiment to verify that the port you have selected is your Arduino board:

With official boards, the port will be labeled with the board name in the menu (e.g., "COM42 (Arduino Uno)"). In this case, you can be fairly confident that you have identified the port. Select that port from the menu and try uploading again.

With some cheap derivative boards the port will not be labeled. You can positively identify the port using this procedure:

  1. Disconnect the USB cable of the Arduino board from your computer.
  2. Select Tools > Port from the Arduino IDE menus.
  3. Take note of the ports, if any, listed in the menu.
  4. Close the Tools menu.
    :exclamation: The ports list is only updated when the Tools menu is re-opened, so this step is essential.
  5. Connect the Arduino board to your computer with a USB cable.
  6. Select Tools > Port from the Arduino IDE menus. - If a new port is listed in the menu, that is the port of your Arduino board.

Select that port from the menu and try uploading again.

If the upload still fails, or if no new port appeared after you plugged the Arduino board into your computer, add a reply here to let us know and we'll investigate the problem further.

1 Like

Hi, still same problem, in tools>port i have only one port visible and that's COM1, tried uploading code i have this error message. WHen i go to device manager>ports only COM1 is listed there and there is no arduino listed there. Let me know if you need anything else.

Sketch uses 7606 bytes (2%) of program storage space. Maximum is 253952 bytes.
Global variables use 326 bytes (3%) of dynamic memory, leaving 7866 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
Failed uploading: uploading error: exit status 1

Everything was working well unitl i tried to add arduino camera to my project that I'm making. had some errors on code I found online and until then i get this error message.

Did you see COM1 in the Tools > Port menu at step (2) of the instructions I provided in my previous reply?

If you saw that port listed in the menu even when the USB cable of the board was disconnected from your computer then you have clear proof that COM1 is not the port of the Mega 2560 board. The upload can never succeed if the wrong port is selected.

So the task now is to try to solve the problem that is causing the board to not produce a port.


It is possible for a short or external circuitry connected to the Arduino board to cause it to no longer produce a port.

Make sure the board is not sitting on anything conductive that could short the contacts on the bottom of the board. Make sure there isn't any conductive debris (e.g., strands of wire or component leads) on the board or on the surface the board is sitting on.

If you have a shield or any external circuitry or components connected to your Arduino board, try this experiment:

  1. Disconnect the USB cable of the Arduino board from your computer.
  2. Disconnect any shields, modules, external circuitry, etc. from your board.
  3. Connect the Arduino board to your computer with a USB cable.

Now check to see whether a port is shown for the board in Arduino IDE's Tools > Port menu. If it does, you know the problem was caused by the external circuitry. You can then focus your attention on identifying the specific problem with the circuit and resolving it.

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