I did the following to fix my issue. Few weeks ago, I had downloaded Tiny Umbrella to restore my iPhone to 4.3.3. Tiny Umbrella has an option under "Advanced" titled "Set Hosts to Cydia on Exit". I had this option checked which permanently modifies the hosts file. Instead of messing with the hosts file, I went back to Tiny Umbrella and unchecked this option. Then, I quit Tiny Umbrella and iTunes, and then opened Terminal and executed "dscacheutil -flushcache" command. After that, I opened iTunes and restored my iPad 2 to iOS 5 without any problem. 
I'm sure this will work with iPhone as well. Give it a try!
I'm sure this will work with iPhone as well. Give it a try!