I forgot the password to my iPhone 5 and it won't connect to Wi-Fi?

My phone restarted on it's own one night and so when i looked at it in the morning i forgot my password since i usually use the finger print. The Wi-Fi and cellular data turned off for a while but it is back on today. I'm trying to restore it on iTunes but it keeps saying an unknown error occurred since it won't connect to Wi-Fi.

If you don't have the passcode you'll have to reset it completely. You can try restoring it thereafter, but if you succeed it will restore the passcode as well.