Here is my solution to this with Android 5.1:
There are three components to it. The last thing or the last part in the process was that I turned the bluetooth off, waited it to be turned off, then turned the bluetooth on, waited it to be turned on, and then connected to wifi, and it worked (so this is the point when I got it on, working, great!).
But before that what I did is I set up the "Tethering & portable hotspot" WLAN hotspot and I updated the password there (generated a new one), - and I think that I also turned the WLAN hotspot on once, and then turned it off.
And hey the third component was that I changed WLAN advanced settings - turned off the "scanning always available" This is also that might have been a factor. So yea, that's that. It might be the combination of things, or silmply one of them.
All-in-all, I am thinking that this problem was caused by something either as in relation with bluetooth or something in relation with the hotspot security thing for what I generated a new code - see above. But most of all, I think it might be that there was some interference with bluetooth, and by rebooting the bluetooth connection it got solved....
(After I got it working I tried to recreate the problem and was unable to create the problem - but I'm fairly sure it will work the next time around as well should I face the same problem).