Simply unplug the cable which connects your iPhone to your computer, and insert it back into the USB port.
Changing USB port can do the trick. Unplug the cable from one USB port, and insert it into another one. Try to restore or update your device.
Check if there is a new version of iTunes software available. If there is, make sure to download it and install it on your computer.
Many users have no idea that security software may cause the error to show up. Update your security software and try again.
If the previous solutions did not fix the problem, turn your security software off. In case the error still appears, uninstall the software from your computer, and try again. Hopefully, this will help. Once you are finished with the restore or update, install the software again.