cannot upload Arduino UNO ATMEGA 328P: avrdude: ser_open(): can't open device

avrdude: ser_open(): can't open device "\.\COM4": The system cannot find the file specified.

I tried different COM ports, still no luck

any help appreciated

Make sure you have selected the port of your Arduino board from the Tools > Port menu.

Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.