Update your Mac or PC
Update your Mac. Or if you have a PC, get updates from Microsoft. If you're using iTunes, make sure that you have the latest version of iTunes.
Plug your device directly into your computer
Plug your iPhone, iPad or iPod directly into your computer's USB port (not into an attached keyboard or USB hub). Make sure that the cable is in good condition.
Make sure that your device is unlocked. If prompted, trust your device.
If an error alert is still appearing, try using a different Apple USB cable or switch to a different USB port on your computer.
Restart your computer and your device
Check your computer’s security software
You might need to update, change or uninstall software that could be interfering with your computer's connection with iTunes.
Use a different computer
Update or restore your device on another computer that uses a different network.