Do you know what to do if your code doesn’t upload? What if you can’t find any way to solve the problem? Whenever you have a problem with uploading a code to Arduino or any other board, don’t panic! There are some common troubleshooting techniques you can use to fix issues like these. In this lesson, we’ll show you some common things to try when troubleshooting, as well as how to solve the common errors you may encounter.
1. Can’t open device “\\.\COM3 or Can’t open device “\\.\COM7 or Can’t open device “\\.\COM10

This is the most common error to upload a code in the Arduino. In this error, you see the following line in the error message.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: ser_open(): can’t open device “\\.\COM3”: The system cannot find the file specified.
To solve this error uploading to Arduino.
Method-1:
Go to Tools>Port>Select the Port
Method-2:
Unplug your board and plug it back in.
Method-3:
Restart your computer or laptop and reinstall Arduino software.
Method-4:
Replace the USB cable.
Method-5:
Reinstall USB driver
2. The selected serial port does not exist or your board is not connected

This is 2nd most common error to upload a code in the Arduino. In this error, you see the following line in the error message.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
The selected serial port does not exist or your board is not connected.
To solve this error uploading to Arduino.
Method-1:
Go to Tools>Board>Select the correct board name
Example:
Tools>Board>Arduino/Genunino
Tools>Board>Generic ESP8266 Module
3. #include <Libraries name> ^ compilation terminated.

In this troubleshooting, you see the following line in the error message.
Error compiling for board Arduino/Genuino Uno.
exit status 1
Error compiling for board Arduino/Genuino Uno.
#include <Libraries name> ^ compilation terminated.
Example: #include <AFMotor.h> ^ compilation terminated.
#include <IRremote.h> ^ compilation terminated.
To solve this error uploading to Arduino.
Method-1:
Go to Sketch>Included Library>Manage Libraries>Search your compilation terminated libraries and Install them.
Another way to upload the library.
Method-2:
First download compilation terminated libraries from www.arduinolibraries.info
Then Go to Sketch>Included Library>Add .ZIP Library>Add the libraries from the downloaded location (Note: The library must be a zip file)