I have a much easier possible solution!!
I had this same issue, trying to connect my new iPhone 5s to my Windows computer's iTunes. I was getting two different error messages:
- iTunes could not connect to the iphone because it is locked with a passcode
- iTunes could not connect to the iphone because the device timed out
I found this thread, but did not like the idea of having to restore my iPhone and losing all my settings/data on the phone. After trying several different things, I discovered that I had 5 devices listed under my "Devices" that were authorized, so the real issue was that I had reached my limit. I had several issues with my old iPhone 5s, and had to have it replaced twice. As a result, I had several old iPhones listed under devices that I no longer had. Erasing those solved the problem, and my new phone connected just fine to iTunes. To get rid of the old devices, you can:
-> click on "store" in the upper left corner
-> from the drop-down menu, select "view account"
-> enter your password
-> under "iTunes in the Cloud", click on the blue "Manage Devices >"
-> remove any old devices
This solved my problem. Hope it helps others as well!