This error can occur in either one of the following cases:
- If your Arduino NANO was purchased earlier than 2018 you have the older official version of Nano. In this case Select Tools > Processor > ATmega328P and select: (Old Bootloader) and try to compile your sketch again. It is also recommended to update Arduino AVR Core 1.16.21 or later through Boards Manager.
- If you have the newer version of the Nano board (manufactured in 2018 or later), make sure you have Arduino AVR Boards 1.6.21 or newer installed. Check this in Arduino IDE: Tools > Board > Boards Manager and select Tools > Processor > ATmega328P.
If you get an error while uploading or you are not sure which bootloader you have, try each type of processor 328P until your board gets properly programmed.